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

Agg pushdown v2 #2

Merged
merged 8 commits into from
Jan 21, 2022
Merged

Agg pushdown v2 #2

merged 8 commits into from
Jan 21, 2022

Conversation

gruuya
Copy link

@gruuya gruuya commented Jan 17, 2022

  • Enable pushdown of qual (WHERE) clauses in combination with aggregations.
  • Additionally, enable pushdown of COUNT(*)

CU-1z461e4

@gruuya
Copy link
Author

gruuya commented Jan 19, 2022

I see one more issue here, and that is that PG isn't rechecking quals for pushed aggregations:

sgr@localhost:splitgraph> SELECT count(*) FROM es.account WHERE firstname ~~ 'Su_an%'
+-------+
| count |
|-------|
| 4     |
+-------+
SELECT 1
Time: 0.019s
sgr@localhost:splitgraph> SELECT count(*) FROM es.account WHERE firstname !~~ 'Su_an%'
+-------+
| count |
|-------|
| 1000  |
+-------+
SELECT 1
Time: 0.013s
sgr@localhost:splitgraph> select count(1) FROM es.account WHERE firstname !~~ 'Su_an%'
+-------+
| count |
|-------|
| 996   |
+-------+
SELECT 1
Time: 0.032s

@gruuya
Copy link
Author

gruuya commented Jan 19, 2022

Ok, I think it's clear to me now after skimming PG source - quals are not meant to be rechecked in case of pushed down aggregations, because if FDW says the pushdown is safe, there's no way to disentangle the returned aggregate result and discard the contributing rows which do not match quals.

Instead, what needs to be done is to reject aggregation pushdown in the plan phase if the qual operator is not supported,here is an example for SQLite FDW.

This allows Multicorn to correctly classify the quals it supports into remote and local conditions.
In turn, this allows us to decide whether pushdown is achievable or not.

Additionally, inquire Python FDW instance about the qual operators it supports.
@gruuya gruuya merged commit 543a450 into master Jan 21, 2022
@gruuya gruuya deleted the agg-pushdown-v2-cu-1z461e4 branch January 21, 2022 11:01
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

Successfully merging this pull request may close these issues.

2 participants