Subject | composite index order - least to most selective? |
---|---|
Author | csswa |
Post date | 2002-05-17T07:48:37Z |
This from an MSSQL7 site:
"When you create an index with a composite key, the order of the
columns in the key is important. Try to order the columns in the key
as to enhance selectivity, with the most selective columns to the
leftmost of the key. If you don't due this, and put a non-selective
column at the first part of the key, you risk having the Query
Optimizer not use the index at all."
I was under the impression that you order left to right, least
selective to most selective field -- the opposite of what this guy
says. I was thinking that least selective first makes for a more
balanced b-tree. No?
Regards,
Andrew Ferguson
-- I have an unhealthy obsession with Freud's mom.
"When you create an index with a composite key, the order of the
columns in the key is important. Try to order the columns in the key
as to enhance selectivity, with the most selective columns to the
leftmost of the key. If you don't due this, and put a non-selective
column at the first part of the key, you risk having the Query
Optimizer not use the index at all."
I was under the impression that you order left to right, least
selective to most selective field -- the opposite of what this guy
says. I was thinking that least selective first makes for a more
balanced b-tree. No?
Regards,
Andrew Ferguson
-- I have an unhealthy obsession with Freud's mom.