Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushdown DISTINCT agg fields as (additional) GROUP BY keys #24

Open
kaikalur opened this issue Mar 20, 2022 · 0 comments
Open

Pushdown DISTINCT agg fields as (additional) GROUP BY keys #24

kaikalur opened this issue Mar 20, 2022 · 0 comments

Comments

@kaikalur
Copy link

kaikalur commented Mar 20, 2022

DISTINCT aggs like COUNT DISTINCT are expensive. But in most cases it is helpful to push down these as group by keys before counting them.

SELECT agg(x), COUNT(DISTINCT y) FROM T GROUP BY z;

can be rewritten as

SELECT agg(x), COUNT(DISTINCT y) FROM (SELECT partial_agg(x) AS x, y, z FROM T GROUP BY y, z) AS T GROUP BY z;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant