Do you set an index on JOIN clauses or where clauses, or both?
I would recommend to always put a non-clustered index on the columns that will be used in JOIN
conditions - the foreign key columns. This helps in several ways - JOIN
operations will be faster, and enforcing the FK constraint (checking whether there's a child row attached when attempting to delete the parent row) will also benefit from those indices.
Then check to see how your system performs. If it performs below your expectations - carefully add one index and see if the overall system performance improves. If not: remove the index again. Repeat over until you're happy with the performance. Columns used in WHERE
or ORDER BY
clauses are the prime candidates for those indices - but don't over-index! That's even worse than having no indices at all.
See Kimberly The Queen of Indexing Tripp's excellent blog post - Indexes: just because can, doesn't mean you should! on that very topic.