Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree with <a href="https://stackoverflow.com/a/179109/50776">Cade Roux</a>.</p> <p>This article should get you on the right track:</p> <ul> <li><a href="http://www.sqlskills.com/BLOGS/KIMBERLY/post.aspx?id=19f0ce1c-0d2f-4ad5-9b13-a615418422e0" rel="noreferrer">Indexes in SQL Server 2005/2008 – Best Practices, Part 1</a></li> <li><a href="http://www.sqlskills.com/blogs/kimberly/indexes-in-sql-server-20052008-part-2-internals/" rel="noreferrer">Indexes in SQL Server 2005/2008 – Part 2 – Internals</a> </li> </ul> <p>One thing to note, clustered indexes should have a unique key (an identity column I would recommend) as the first column. Basically it helps your data insert at the end of the index and not cause lots of disk IO and Page splits.</p> <p>Secondly, if you are creating other indexes on your data and they are constructed cleverly they will be reused. </p> <p>e.g. imagine you search a table on three columns</p> <p>state, county, zip. </p> <ul> <li>you sometimes search by state only. </li> <li>you sometimes search by state and county.</li> <li>you frequently search by state, county, zip. </li> </ul> <p>Then an index with state, county, zip. will be used in all three of these searches.</p> <p>If you search by zip alone quite a lot then the above index will not be used (by SQL Server anyway) as zip is the third part of that index and the query optimiser will not see that index as helpful. </p> <p>You could then create an index on Zip alone that would be used in this instance.</p> <p>I guess the answer you are looking for is that it depends on your where clauses of your frequently used queries and also your group by's.</p> <p>The article will help a lot. :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload