5

有没有办法提前(不是通过反复试验)确定特定查询应该使用 GROUP BY 还是 GROUP EACH BY?我们目前看到,在约 60-70% 的基数之后,我们被要求使用 Group EACH。当我们生成 SQL 时,很难预测。

4

1 回答 1

5

The usage of 'EACH' doesn't depend on the query, but on the data. Is there a small number of unique values for the group expression? Use GROUP BY. Is there a lot? Use GROUP EACH BY.

The best strategy is to use GROUP BY until you get an "over limits error".

To go deeper into the "why?", you can look at the Dremel paper that started it all. Basically GROUP BY runs in the mixers, while GROUP EACH BY gets pushed to the shards.

For other insights, check jcondit's answers at Resources Exceeded during query execution.

于 2013-06-06T01:30:50.817 回答