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:
from SomeFact f
join SomeDim d on f.dimensionKey = d.dimensionKey
d.dimensionName, -- large number of unique values
d.dimensionCategory -- small number of unique values
No, the order doesn't matter for the GROUP BY clause.
MySQL and SQLite are the only databases I'm aware of that allow you to select columns which are omitted from the group by (non-standard, not portable) but the order doesn't matter there either.