SQL Optimization: how many columns on a table?

后端 未结 13 966
离开以前
离开以前 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 13:57

    Usually excess columns points to improper normalization, but it is hard to judge without having some more details about your requirements.

    0 讨论(0)
  • 2021-01-01 14:03

    I'm in a similar position. Yes, there truly is a situation where a normalized table has, like in my case, about 90, columns: a work flow application that tracks many states that a case can have in addition to variable attributes to each state. So as each case (represented by the record) progresses, eventually all columns are filled in for that case. Now in my situation there are 3 logical groupings (15 cols + 10 cols + 65 cols). So do I keep it in one table (index is CaseID), or do I split into 3 tables connected by one-to-one relationship?

    0 讨论(0)
  • 2021-01-01 14:04

    The UserData table in SharePoint has 201 fields but is designed for a special purpose.
    Normal tables should not be this wide in my opinion.

    You could probably normalize some more. And read some posts on the web about table optimization.

    It is hard to say without knowing a little bit more.

    0 讨论(0)
  • 2021-01-01 14:04

    Columns in a table1 (merge publication) 246

    Columns in a table2 (SQL Server snapshot or transactional publication) 1,000

    Columns in a table2 (Oracle snapshot or transactional publication) 995

    in a table, we can have maximum 246 column

    http://msdn.microsoft.com/en-us/library/ms143432.aspx

    0 讨论(0)
  • 2021-01-01 14:04

    A table should have as few columns as possible.....

    in SQL server tables are stored on pages, 8 pages is an extent

    in SQL server a page can hold about 8060 bytes, the more data you can fit on a page the less IOs you have to make to return the data

    You probably want to normalize (AKA vertical partitioning) your database

    0 讨论(0)
  • 2021-01-01 14:07

    It sounds like you have potential normalization issues.

    If you really want to, you can create a new table for each of those columns (a little extreme) or group of related columns, and join it on the ID of each record.

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