Home Forums SQL Server 2005 Administering Adding columns to a Index As key Vs Non-key columns RE: Adding columns to a Index As key Vs Non-key columns

  • There is no point adding all columns as key columns unless you have queries which use all the columns in joins/where/group by clauses.

    You also have a 900 byte limit on key columns.

    Also adding too many non-key columns is going to cause grief:

    http://msdn.microsoft.com/en-us/library/ms190806%28v=sql.105%29.aspx

    Performance Considerations

    Avoid adding unnecessary columns. Adding too many index columns, key or nonkey, can have the following performance implications:

    Fewer index rows will fit on a page. This could create I/O increases and reduced cache efficiency.

    More disk space will be required to store the index. In particular, adding varchar(max), nvarchar(max), varbinary(max), or xml data types as nonkey index columns may significantly increase disk space requirements. This is because the column values are copied into the index leaf level. Therefore, they reside in both the index and the base table.

    Index maintenance may increase the time that it takes to perform modifications, inserts, updates, or deletes, to the underlying table or indexed view.

    You will have to determine whether the gains in query performance outweigh the affect to performance during data modification and in additional disk space requirements. For more information about evaluating query performance, see Query Tuning.