May 22, 2008 at 10:07 am
Hello,
I am looking for more information on how Indexes parse multiple fields, and the benefits of ordering the fields in the index.
Say have a table with the following data (in comma delimited format)
(Person_id is the PK.)
person_id, gender, name
1,M,Bob
2,M,Joe
3,F,Jan
4,M,Allan
5,F,Ellen
6,M,Paul
....
303892,F,Selma
If I had to make an index of all three columns, how would the keys be represented in the index? Would it be a concatenation of all 3 columns? If so, it would make sense to put the column with the least distinct values first (Gender). However, if I wanted fast searching on all 3 fields, do I create 1 index (gender,person_id,name) or two separate indexes (gender,person_id) and (name, person_id).
May 22, 2008 at 11:47 am
It mainly depends on the queries that use that table.
There have been a couple discussions on this the last few weeks. These 2 threads should get you started. If you still have questions after, please post them.
http://www.sqlservercentral.com/Forums/Topic504600-145-1.aspx
http://www.sqlservercentral.com/Forums/Topic488867-65-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply