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 ex
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?
Query-1
SELECT spec_id, catid, spec_display_value, COUNT(*) AS cnt FROM tbl_product_spec
GROUP BY spec_id, catid, spec_display_value ;
Query-2
SELECT spec_id, catid, spec_display_value, COUNT(*) AS cnt FROM tbl_product_spec FORCE INDEX(idx_comp_spec_cnt)
GROUP BY catid, spec_id,spec_display_value;
Both are equal , order doesn't work in group by clause.