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

✨ Push filters (HAVING) into aggregates #1713

Open
joocer opened this issue May 31, 2024 · 0 comments
Open

✨ Push filters (HAVING) into aggregates #1713

joocer opened this issue May 31, 2024 · 0 comments
Labels
⚙️ Query Optimizer Component Label - Optimizer

Comments

@joocer
Copy link
Contributor

joocer commented May 31, 2024

Combining Filters and Aggregation:

If possible, combine the COUNT(*) > 100000 filter with the aggregation step to minimize intermediate results.

SELECT CounterID, AVG(length(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
   └─ HEAP SORT (LIMIT 25, ORDER BY l DESC)
      └─ FILTER (COUNT(*) > 100000)
         └─ PROJECT (AVG(LENGTH(URL)), COUNT(*), CounterID)
            └─ AGGREGATE (AVG(LENGTH(URL)), COUNT(*)) GROUP BY (CounterID) [!!!FILTER HERE!!!]
               └─ READ (hits) [CounterID, URL] (URL != '')
@joocer joocer added the ⚙️ Query Optimizer Component Label - Optimizer label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ Query Optimizer Component Label - Optimizer
Projects
None yet
Development

No branches or pull requests

1 participant