Does the order of columns matter in a group by clause?

前端 未结 5 1100

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

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 17:27

    SQL is declarative.

    In this case, you have told the optimiser how you want the data grouped and it works out how to do it.

    It won't evaluate line by line (procedural) and look at one column first

    The main place column order matters is for indexes. col1, col2 is not the same as col2, col1. At all.

提交回复
热议问题