What the f**k..
I see a lot of code from other developers and every now and then you see some real gems. Today I was looking at a query to see if and how it could be optimised. One of the things I did was look at the query plan to see if indexes were used for various joins. One of the items in the plan made me look at a table definition, to check on it's indexes.
I then discovered that one of the tables joined into the query contained an index on every column?!?!?! I checked other queries that used the same table and discovered that all joins on that table were made on the column that made up the primary key. That primary key was a clustered index, so barely impossible to try and optimize that.
The F**K factor in this is of course what in heavens name posessed the developer that designed that table was actually thinking. The table contains 10 columns and 10 indexes. I removed all but the primary key and the query still performed as it was. Inserts and updates on the table are flying now, obviously.
Motto: Think before you index a column!!