Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

I hail from Chennai and hold a Masters degree in Computer Applications. I am into IT for more than a decade now. Presently, I model the role of a Senior Project Manager with Verizon Data Services India Pvt. Ltd., I have been MVP in SQL Server (2006-08, 2012) & .NET (2003-04).
Browse by Tags · View All
SQL Server 4
SSMS 2
Alter to 1
Data length 1
Bad Practice 1
BIGINT 1

Archive · View All
July 2012 4

Vadivel's (We)blog

BIGINT - Upper limit - Overflow - SQL Server

Jul 4 2012 12:00AM by Vadivel   

BIGINT upper limit is 2^63-1 (9,223,372,036,854,775,807). For complete reference check out this MSDN article

Recently I was asked when we use INT data type and it reaches its limit what do we do? The following is the error message we would see when it reaches its upper limit.

Arithmetic overflow error converting IDENTITY to data type int.
Arithmetic overflow occurred.

Though there are multiple solutions, one of the option for us is to change the datatype to BIGINT.

The person who asked me wasn't satisfied with this answer. He was worried is this a permanent solution? Won't BIGINT also overflow / reach its limits sooner or later?

Obviously BIGINT would also reach its limit but it would take really LOTS of years + millions of transactions per second for it. Actually I wouldn't bother about it at all for the reasons explained below.

Let's take few examples and see how many years will it take for BIGINT to reach its upper limit in a table:

(A) Considering only positive numbers, Max limit of BIGINT = 9,223,372,036,854,775,807
(B) Number of Seconds in a year = 31,536,000

Assume there are 50,000 records inserted per second into the table. Then the number of years it would take to reach the BIGINT max limit is:

9,223,372,036,854,775,807 / 31,536,000 / 50,000 = 5,849,424 years

Similarly,
If we inserted 1 lakh records per second into the table then it would take 2,924,712 yrs
If we inserted 1 million (1000000) records per second into the table then it would take 292,471 yrs
If we inserted 10 million (10000000) records per second into the table then it would take 29,247 yrs
If we inserted 100 million records per second into the table then it would take 2,925 yrs
If we inserted 1000 million records per second into the table then it would take 292 yrs

By this we would have understood that it would take extremely lots of years to reach the max limit of BIGINT. May be end of world would be earlier than this :) Atleast I have not seen (or) heard of any application which has exceeded the BIGINT's max limit as of now. Please feel free to let me know if you have seen any.

By the way, if you are wondering how we calculated the number of seconds in a year.
It is just 365 days * 24 hours * 60 minutes * 60 seconds = 31,536,000 seconds.


Originally Posted here

Tags: SQL Server, BIGINT


Vadivel
474 · 0% · 79
11
 
0
Lifesaver
 
 
0
Learned
 
0
Incorrect



Submit

11  Comments  

  • You may be interested in these posts I wrote way back (about an year ago). They deal with the same issue arising out of working with integration to a UNIX system (based on a practical experience I had):

    commented on Jul 5 2012 12:28AM
    Nakul Vachhrajani
    4 · 33% · 10585
  • Vadivel, you forgot the negative values. So in fact number of years should be doubled if you include negatives :)

    commented on Jul 5 2012 2:03AM
    Madhivanan
    3 · 39% · 12430
  • Sometimes, altering the column may not be a quick option. Especially if the database needs to be up 24x7 and if you don't have a proper maintenance window. You may need to drop primary-keys/indexes or if the table is replicated you may have another set of troubles.

    So a quick fix when this happens could be to RESEED the identity value to the biggest negative number supported by that data type (most well-written applications may not break with NEGATIVE identity values). This will give you some breathing space to 'think' properly. It is always a challenge when something goes wrong on the production server. The application stops working, users start complaining, phones start ringing and you really need a 'first-aide' available immediately to put the application back on-line.

    Also, it may be worth considering that when rows are deleted and transactions are rolled back, we loose identity values. So a table may have 10K records, but the highest identity value may be 500K. So they get eaten up much quicker than we would assume :-)

    commented on Jul 5 2012 2:51AM
    Jacob Sebastian
    1 · 100% · 32004
  • Madhivanan,

    Actually I have mentioned that "(A) Considering only positive numbers". Yeah once we consider Negative values as well then its gonna be double :)

    Disclaimer: I am relatively new to this site. Still trying to figure out the various options. So pls bare with me if there is any delay in my response :)

    commented on Jul 5 2012 7:49AM
    Vadivel
    474 · 0% · 79
  • Jacob,

    I agree. Actually intention of this post was not to show the readers the various ways of overcoming INT overflow. My intention was to show how long a BIGINT can survive before it reaches the max limit.

    commented on Jul 5 2012 7:51AM
    Vadivel
    474 · 0% · 79
  • Nakul,

    Thanks for those links. Would check it out.

    commented on Jul 5 2012 7:53AM
    Vadivel
    474 · 0% · 79
  • @Vadivel,

    Absolutely. I agree with you. My intention was to add some related stuff that may be helpful to people reading this thread.

    Please note that the "You" in my comment did not refer to "YOU" (author of the post) :-). It was more referring to the reader of the post. So texts like "You may need to drop primary-keys/indexes or if the table is replicated you may have another set of troubles." really meant "A user who intend to alter the data type of a column may need to drop primary.......blah blah" etc. So the 'you" in my posts always intended to addresses the readers. (Time to change my writing style :-)

    I found your post really interesting. We do have many tables having BIGINT data types. I do even have a script/application that scans all the tables, checks for the values and alerts us if we are reaching the maximum limit of any columns in the various databases we have (we have columns that are tinyint, smallint, int, and big int etc). I very much knew the maximum limit of BIGINT, but never tried to do the math to find how long we can go till we hit the limit. We always considered 'one day' we will hit the limit.

    I just realized that it may be my daughter's grand children who may need to worry about the BIGINT columns that I created a few years ago.

    Looking forward to see more posts...

    commented on Jul 5 2012 8:14AM
    Jacob Sebastian
    1 · 100% · 32004
  • "You" in my comment did not refer to "YOU" (author of the post) :-). It was more referring to the reader of the post. So texts like "You may need to drop primary-keys/indexes or if the table is replicated you may have another set of troubles." really meant "A user who intend to alter the data type of a column may need to drop primary.......

    Although it may sound snobbish, the correct and succint way would be to say "One may need to drop primary-keys/indexes..."

    My 'two pennies' as an Enlgishman :)

    commented on Jul 5 2012 9:22AM
    a.diniz
    310 · 0% · 137
  • Agreed. Thanks

    commented on Jul 5 2012 9:44AM
    Jacob Sebastian
    1 · 100% · 32004
  • You forgot to factor in leap years in your calculations! :-)

    It is just 365.24 days * 24 hours * 60 minutes * 60 seconds = 31,556,736.

    commented on Jul 6 2012 5:29AM
    Sequin
    2271 · 0% · 5
  • This post reminds me my post on Time to write the result of 10^10^10

    commented on Jul 6 2012 6:00AM
    Madhivanan
    3 · 39% · 12430

Your Comment


Sign Up or Login to post a comment.

"BIGINT - Upper limit - Overflow - SQL Server" rated 5 out of 5 by 11 readers
BIGINT - Upper limit - Overflow - SQL Server , 5.0 out of 5 based on 11 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]