Clustered index dilemma - ID or sort?
Posted
by
richardtallent
on Stack Overflow
See other posts from Stack Overflow
or by richardtallent
Published on 2011-01-11T16:44:20Z
Indexed on
2011/01/11
16:54 UTC
Read the original article
Hit count: 311
I have a table with two very important fields:
id INT identity(1,1) PRIMARY KEY
identifiersortcode VARCHAR(900)
My app always sorts and pages search results in the UI based on identifiersortcode
, but all table joins (and they are legion) are on the id
field. (Aside: yes, the sort code really is that long. There's a strong BL reason.)
Also, due to O/RM use, most SELECT statements are going to pull almost every column.
Currently, the clustered index is on id
, but I'm wondering if the TOP / ORDER BY portion of most queries would make identifiersortcode
a more attractive option as the clustered key, even considering all of the table joins going on.
Inserts on the table and changes to the identifiersortcode
are limited enough that changing my clustered index would be a problem for insert/update operations.
Trying to make the sort code's non-clustered index a covering index (using INCLUDE
) is not a good option. There are a number of large columns, and some of them have a lot of update activity.
© Stack Overflow or respective owner