Remember the Sort Order of Indexes…

I just add a non-clustered index to a table because a large join using the table was running like a dog when I sorted on certain numeric field.

Added the index and rebuilt it and … nothing! Villainy… seek it out!! I was halfway through selling my Microsoft shares when…

…I realised that the full value of an index is only realised when the index’s sort direction is aligned with that of the SQL your trying to speed up. Why? Because indexes are all about how stuff lined up on disk. And if it’s the wrong order the cursor can’t read it out efficiently…

Maybe some coffee…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: