Adding indexes is often suggested here as a remedy for performance problems.
(I'm talking about reading & querying ONLY, we all know indexes can make writing slower).
I have tried this remedy many times, over many years, both on DB2 and MSSQL, and the result were invariably disappointing.
My finding has been that no matter how 'obvious' it was that an index would make things better, it turned out that the query optimiser was smarter, and my cleverly-chosen index almost always made things worse.
I should point out that my experiences relate mostly to small tables (<100'000 rows).
Can anyone provide some down-to-earth guidelines on choices for indexing?
The correct answer would be a list of recommendations something like:
- Never/always index a table with less than/more than NNNN records
- Never/always consider indexes on multi-field keys
- Never/always use clustered indexes
- Never/always use more than NNN indexes on a single table
- Never/always add an index when [some magic condition I'm dying to learn about]
Ideally, the answer will give some instructive examples.