SQL Server Int or BigInt database table Ids -


I am writing a new program and it will need the database (SQL Server 2008). Now what I am running for the system is 64-bit, which brings me to this question. For all the ID columns in different tables, can I have them all INT or BIGINT? I suspect that the system will never cross the INT range, but it seems to me that there is a possibility within some big financial tables. It seems that INT is the standard though ...

OK, let's quickly recapture an INT 32-bit and gives you basically 4 billion worth - if you only calculate values ​​greater than zero, then it's still 2 billion. Do you have many employees? Customers? Products in stock? Orders in the lifetime of your company? Actually?

  • The Beginnum moves ahead of that path. Do you really need ?? Really ?? If you are an astronomer, or particle physics - perhaps an average line of business user? I suspect

  • Imagine that you have a table - say - 10 million rows (order for your company). Let's say you have an order table, and the order id that you have made has been referenced by 5 other tables, and has been used on your order table in 5 non-clustered indexes - not much, I It seems, right?

    By 10 million rows, 5 tables, and 5 non-clustered indexes, which are 100 million instances, where you are using 8 bytes instead of 4 bytes - 400 million bytes = 400 MB . Total waste ... You will need more data and index pages, your SQL server will have to read more pages from the disk and cache more pages ... which is not beneficial for your performance - plain and simple .

    Plus: What is not to think about most programmers: Yes, this dirt in the disk space is cheap but this waste space is also relevant in your SQL server RAM memory and your database cache - and this location is messy Not cheap!

    Shorten for a very long time: actually use the smallest type INT according to your needs; If you have to handle 10-20 different values ​​- Use TINYINT if you need an order table, then I believe INT should be very suitable - only start There is a waste of space.

    Plus: Should you come close to reaching any table in any of the 2 or 4 billion rows, if you really need it, then you have a lot to upgrade your table to a bigger ID Time will be .......


    Comments

    Popular posts from this blog

    oracle - The fastest way to check if some records in a database table? -

    php - multilevel menu with multilevel array -

    jQuery UI: Datepicker month format -