I use indexes regularly but it's still hard for me in certain conditions to know if they are helping or hurting. There are a few guidelines I follow, but I am not sure if they are good nor am I sure of their justification.
It is better to create an index on a narrow datatype than it is on a wide datatype (e.g.
INT
overDATETIME
).It is better to create an index on multiple columns than it is on a single column.
It is better to create an index on a column that is never (or rarely) updated than it is to index frequently changing columns.
Are these good guidelines? Since I'm not entirely sure why I follow these guidelines, can you help explain what is the justification for each and when would they not apply?