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

[Optimizer] Add a new rule to prune no-used columns to speed up query performance for aggregate-union-aggregate pattern #55285

Open
LiShuMing opened this issue Jan 21, 2025 · 0 comments
Labels
type/enhancement Make an enhancement to StarRocks

Comments

@LiShuMing
Copy link
Contributor

Enhancement

For the query below, we can do som optimizations if:

  • parent's aggs can be roll-up and rollup from union's aggs;
  • parent's gb-keys comes from union's gb-keys.

before

select col1, sum(col3) from --  parent
(

	select col1, col2, sum(col3) as col3 from t1 group by col1, col2 -- child
	union all
	select col1, col2, sum(col3) as col3 from t1 group by col1, col2
) t
group by col1;

after:

select col1, sum(col3) from
(

	select col1, sum(col3) as col3 from t1 group by col1
	union all
	select col1, sum(col3) as col3 from t1 group by col1
) t
group by col1;

This can prune no-used columns to speed up query performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Make an enhancement to StarRocks
Projects
None yet
Development

No branches or pull requests

1 participant