Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

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.

@Gun9niR Gun9niR requested a review from wangpatrick57 March 30, 2024 22:13
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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants