Ok, do a math summary:
INT is 32-bit and gives you basically 4 billion values - if you only count values greater than zero, that's 2 billion more. Do you have a lot of employees? Customers? Products in stock? Orders for the whole life of your company? REALLY?
BIGINT goes a lot further. Do you really need this? really ?? If you are an astronomer or particle physics - maybe. Average business user identity? I doubt it very much
Imagine you have a table with - say - 10 million rows (orders for your company). Say you have an Orders table, and that the OrderID that you created BIGINT refers to 5 other tables and is used in 5 non-clustered indexes in your Orders table - don't overdo it, I think, right?
10 million rows, 5 tables each plus 5 non-clustered indexes, 100 million instances in which you use 8 bytes instead of 4 bytes - 400 million bytes = 400 MB. Total waste ... you need more data and index pages, your SQL Server will need to read more pages from disk and cache more pages ... which is not beneficial for your performance - simple and simple.
PLUS: that most programmers don’t think: yes, disk space is dirty cheap. But this wasted space is also relevant in your SQL Server RAM and database cache - and this space is not cheap!
So, to make a very long record short: use the smallest type of INT that really suits your needs; if you have 10-20 different values for processing, use TINYINT. If you need an order table, I believe INT should be PLENTY ENOUGH . BIGINT is just a waste of space.
Plus: if any of your tables really comes close to reaching 2 or 4 billion rows, you will still have enough time to update the table to BIGINT ID, if it is really necessary .......
marc_s Jan 23 '10 at 20:57 2010-01-23 20:57
source share