SQL Optimization: how many columns on a table?

后端 未结 13 967
离开以前
离开以前 2021-01-01 13:43

The current project that I\'m working on have table with 126 columns and the least that i saw is at least 50 columns. Should a table hold less columns per table or separate

相关标签:
13条回答
  • 2021-01-01 14:23

    Here are the official statistics for SQL Server 2005 http://msdn.microsoft.com/en-us/library/ms143432.aspx

    Keep in mind these are the maximums, and are not necessarily the best for usability.

    Think about splitting the 126 columns into sections. For instance, if it is some sort of "person" table you could have

    Person ID, AddressNum, AddressSt, AptNo, Province, Country, PostalCode, Telephone, CellPhone, Fax

    But you could separate that into Person ID, AddressID, PhoneID

    Address ID, AddressNum, AddressSt, AptNo, Province, Country, PostalCode

    Phone ID, Telephone, Cellphone, fax

    In the second one, you could also save yourself from data replication by having all the people with the same address have the same addressId instead of copying the same text over and over.

    0 讨论(0)
提交回复
热议问题