July 16, 2012 at 9:25 am
I am joing few tables on 3 columns - 2 of them are integers and 1 is a varchar. Should i create a composite index with these three columns on the joining tables or three individual indexes on all the joing tables
July 16, 2012 at 9:35 am
1 index.
SQL Server won't use multiple indexes usually. It just makes more work for it. Should be one index, and you'll need to pick the leading edge (first column in the index) based on your query and on selectivity of the columns involved. The one with the most selective values should usually lead the index.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
July 16, 2012 at 10:06 am
http://sqlinthewild.co.za/index.php/2010/09/14/one-wide-index-or-multiple-narrow-indexes/
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 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply