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(optimizer): improve pull_up_correlated_predicate_agg_rule to optimize TPCH Q17 #15383

Merged
merged 6 commits into from
Mar 6, 2024

Conversation

chenzl25
Copy link
Contributor

@chenzl25 chenzl25 commented Mar 1, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Resolve better query rewrite for TPC-H q17 #15247 (comment)
  • Support count aggcall for pull_up_correlated_predicate_agg_rule if it can be proved that the row generated by empty input finally being able to be eliminated.
  • Actually, the Q17 could be further optimized with the Window operator, but it is out of the scope of this PR.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@st1page
Copy link
Contributor

st1page commented Mar 1, 2024

Actually, the Q17 could be further optimized with the Window operator, but it is out of the scope of this PR.

I am not sure if it could be better in stream because the streaming OverWindow operator is more expensive

@chenzl25
Copy link
Contributor Author

chenzl25 commented Mar 1, 2024

Actually, the Q17 could be further optimized with the Window operator, but it is out of the scope of this PR.

I am not sure if it could be better in stream because the streaming OverWindow operator is more expensive

It reminds me why our agg executor could emit messages when the barrier arrives, however, window executor can't do it in the same way?

Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

generally LGTM, maybe add the case #15026 (comment) in the planner test?

Copy link
Contributor

@lmatz lmatz left a comment

Choose a reason for hiding this comment

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

The improved TPC q17 LGTM!
link: #14799 (comment)

@chenzl25 chenzl25 added this pull request to the merge queue Mar 6, 2024
Merged via the queue into main with commit 23e0388 Mar 6, 2024
26 of 27 checks passed
@chenzl25 chenzl25 deleted the dylan/improve_pull_up_correlated_predicate_agg_rule branch March 6, 2024 05:30
Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +181 to +184
let mut agg_null_bitset = FixedBitSet::with_capacity(agg.base.schema().len());
for pos in null_agg_pos {
agg_null_bitset.insert(pos);
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you looking for FixedBitSet::from_iter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to ensure the capacity of this bitset is agg.base.schema().len().

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

Successfully merging this pull request may close these issues.

better query rewrite for TPC-H q17
4 participants