Skip to content

Conversation

@WangGuangxin
Copy link
Contributor

@WangGuangxin WangGuangxin commented May 21, 2022

What changes were proposed in this pull request?

Currently we can do subexpression elimination for conditional expressions when the subexpression is common across all branchGroups. In fact, we can farther improve this when there are common expressions between alwaysEvaluatedInputs and branchGroups.

Why are the changes needed?

Take the following case as an example

IF(IsNull(a), b, KnowNotNull(a))

a may miss subexpression elimination chances since it is not the common expression between all branchGroups, but it's safe to evaluate a as common subexpression and eagerly execute it since it's part of the prediction, which will always be executed. If a is a time-expensive expression, we may waste time on running it.

This kind of expressions are common when we do sum on decimal type because of #29026

Many queries on TPC-DS has positive improvement. Following is some obvious improvements on TPC-DS 10T

Query With this PR Without this PR Speed up
4 310.862 635.299 104.37%
44 47.851 63.717 33.16%
50 188.106 217.023 13.32%
80 36.723 46.006 25.28%
93 193.26 224.135 13.78%
95 102.811 126.125 18.48%

Does this PR introduce any user-facing change?

No

How was this patch tested?

add more UT.

@github-actions github-actions bot added the SQL label May 21, 2022
@WangGuangxin
Copy link
Contributor Author

@viirya @cloud-fan Could you please help review this?

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@Kimahriman
Copy link
Contributor

Kimahriman commented May 21, 2022

FYI I created #32987 a while ago to address this in a more general way. I've tried to keep it up to date, but there seemed to be concerns about creating a subexpression for something that might only execute once I guess? Even though that's already happening in certain cases

@WangGuangxin
Copy link
Contributor Author

@viirya @cloud-fan Could you please help review this?

@github-actions
Copy link

We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!

@github-actions github-actions bot added the Stale label Sep 15, 2022
@github-actions github-actions bot closed this Sep 16, 2022
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.

3 participants