Jan Schreuder on .Net

.Net code samples, experiences, observations

View my professional profile on LinkedIn

Recent Posts

Tags

News

  • Inappropriate comments will be deleted at my discretion.

    The information and code samples in this weblog is provided "AS IS" without warranty of any kind, either expressed or implied, including but not limited to the merchantability and/or fitness for a particular purpose.

Community

Email Notifications

Tool suppliers

Tools

General

Microsoft

Favorite blogs

Archives

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!!

Comments

Wim said:

Some 'developers' have no clue about what they are doing. So they become project managers and complain about projects not finished in time ;-)

# November 4, 2008 8:17 AM

Dan said:

I'm sure you've heard of thedailywtf.com?  To some developers, index=speed, so why not index every column to make it as fast as possible.

# August 6, 2009 3:25 PM

Ewan said:

He should also have added an index for each possible combination of columns.

# January 25, 2010 3:11 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Please add 5 and 3 and type the answer here: