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

feat: add cost estimation for agg #144

Merged
merged 9 commits into from
Mar 31, 2024
Merged

feat: add cost estimation for agg #144

merged 9 commits into from
Mar 31, 2024

Conversation

Gun9niR
Copy link
Contributor

@Gun9niR Gun9niR commented Mar 30, 2024

Compute cost for aggregation. The cardinality is computed as the product of n-distinct of all the group-by columns. If there's no group by column, the output cardinality is just 1.

This should fix the cardinality parity between postgres for Q14 and Q17. It also leads to a better join order in Q11, since aggregation is the child of a join.

Misc

  • Add planner test for Q11.
  • Fixes Q14 and Q17.
  • Next step is to support n-distinct for string.
  • We may change to multi-dimension n-distinct after it's integrated.

Copy link
Member

@wangpatrick57 wangpatrick57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than small changes

optd-datafusion-repr/src/cost/base_cost.rs Outdated Show resolved Hide resolved
optd-datafusion-repr/src/cost/base_cost.rs Outdated Show resolved Hide resolved
optd-datafusion-repr/src/properties/schema.rs Outdated Show resolved Hide resolved
optd-datafusion-repr/src/properties/schema.rs Outdated Show resolved Hide resolved
@wangpatrick57
Copy link
Member

Oh one more thing, could you update the q-errors in #127 after each PR? This way, we always know which PR caused which changes to the q-errors? I noticed that you marked Q14 as fixed but didn't update dfcard

@Gun9niR Gun9niR merged commit ee080d8 into main Mar 31, 2024
1 check passed
@Gun9niR Gun9niR deleted the zhidong/agg branch March 31, 2024 01:36
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.

None yet

2 participants