Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't just create an index on every single column - that's a total waste of time and resources!</p> <p>Basically, my approach is always:</p> <ol> <li><p>define a <strong>good</strong> primary and clustering key on any "normal" table (except for e.g. staging tables etc.) - that's a big step already</p></li> <li><p>put non-clustered indices on any foreign key columns - those really help a lot, especially with JOIN's</p></li> </ol> <p>And that's it!</p> <p><strong>Then:</strong> </p> <ul> <li>observe your system - see when things are slow</li> <li>measure system performance</li> <li>capture a server-side trace to get a representative workload</li> <li>analyse that workload, and see what additional indices might be helpful </li> <li>do tweaks - one at a time</li> <li>measure again and again to see if you've improved system performance (or not)</li> </ul> <p>You need a full, representative workload to see what queries are really common and used a lot - and see what indices might be beneficial for those frequent queries. Otherwise, you might be providing index help for all the wrong queries, and you might actually slow things down ...</p> <p>You'd be surprised just how rarely non-clustered indices will really help!</p> <p>Don't <strong>over-index</strong> - it's just as bad - if not worse - than having no indices at all ! It might be worse, because every index that you have will also need to be <strong>maintained</strong> over its lifetime... and there ain't no free lunch - not even here...</p> <p>See Kimberly Tripp's excellent blog post <a href="http://www.sqlskills.com/BLOGS/KIMBERLY/post/Indexes_JustBecauseUCan_NO.aspx" rel="nofollow">Indexes: just because you can doesn't mean you should!</a> on the topic - very helpful, lots of insights. Or basically, <a href="http://www.sqlskills.com/blogs/kimberly/category/indexes.aspx" rel="nofollow">just read anything Kim has blogged on indexes</a> - she's the <em>Queen of Indexing</em> and anything she's posted on her blog is usually extremely helpful and beneficial!</p> <p>Furthermore, SQL Server 2005 and newer offer DMV's (Dynamic Management Views) that allow you to find out what indices are not being used (those can be removed) or which are missing, according to SQL Server's query optimizer's opinion. See <a href="http://weblogs.sqlteam.com/mladenp/archive/2009/04/08/SQL-Server---Find-missing-and-unused-indexes.aspx" rel="nofollow">SQL Server - Find missing and unused indexes</a> for more details. But be aware: those are <strong>dynamic</strong> views - they're reset with each system start and might not be totally accurate - don't just do everything they tell you - take everything with a grain of salt and consider carefully what you do - document it, so that you can undo it, if things get worse rather than better!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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