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

Eliminate the agg if possible when it's built #45193

Open
winoros opened this issue Jul 5, 2023 · 2 comments
Open

Eliminate the agg if possible when it's built #45193

winoros opened this issue Jul 5, 2023 · 2 comments
Assignees
Labels
sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@winoros
Copy link
Member

winoros commented Jul 5, 2023

Enhancement

Currently, we eliminate the aggregation after it's built.

So consider the following case:
select max(a) from t group by b
The b is a unique & not null column. So the aggregation can be eliminated. But we will allocate a new column for max(a)(such as col#x, for example). Then we get a projection proj(a->col#x(which is max(a)) This projection cannot be eliminated in the whole optimization phase because we'll need to re-construct the output columns for the whole parent plan operators of the projection to replace the column col#x to column a.
This breaks the rule that an optimization rule should only affect a small part of the plan tree.

This projection might block other optimizations, such as that this projection cuts a join tree into two parts, so the join reorder cannot be performed as much as we can.

We need to eliminate the aggregation as early as possible to avoid such cases.

@winoros winoros added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner labels Jul 5, 2023
@winoros
Copy link
Member Author

winoros commented Jul 5, 2023

😂 and another reason is that we want to remove the physical projection elimination, which caused the issue #45112

@fixdb
Copy link
Contributor

fixdb commented Sep 19, 2023

/assign @hawkingrei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants