Does the order of columns matter in a group by clause?
Posted
by Jeff Meatball Yang
on Stack Overflow
See other posts from Stack Overflow
or by Jeff Meatball Yang
Published on 2010-06-17T18:55:34Z
Indexed on
2010/06/17
19:03 UTC
Read the original article
Hit count: 294
If I have two columns, one with very high cardinality and one with very low cardinality (unique # of values), does it matter in which order I group by?
Here's an example:
select
dimensionName,
dimensionCategory,
sum(someFact)
from SomeFact f
join SomeDim d on f.dimensionKey = d.dimensionKey
group by
d.dimensionName, -- large number of unique values
d.dimensionCategory -- small number of unique values
Are there situations where it matters?
© Stack Overflow or respective owner