-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
opt: add rule to eliminate Exists when input has zero rows #48162
Conversation
This commit adds a new rule, EliminateExistsZeroRows, which converts an Exists subquery to False when it's known that the input produces zero rows. Informs cockroachdb#47058 Release note (performance improvement): The optimizer can now detect when an Exists subquery can be eliminated because the input has zero rows. This leads to better plans in some cases.
❌ The GitHub CI (Cockroach) build has failed on 67a1d4d7. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @RaduBerinde)
Thanks for looking into the regression! I added an entry to #43438 to propagate soft-limit of 1 to Exists input (not exactly related to this change, but the tests around the rule that removes Limit made me think of it). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @rytaft)
a discussion (no related file):
What a simple and beautiful rule!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TFTRs! And thanks for adding that TODO for soft-limit 1 for Exists, @RaduBerinde.
bors r+
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @rytaft)
Build failed (retrying...) |
Build succeeded |
This commit adds a new rule,
EliminateExistsZeroRows
, whichconverts an
Exists
subquery to False when it's knownthat the input produces zero rows.
Informs #47058
Release note (performance improvement): The optimizer can now
detect when an Exists subquery can be eliminated because the input
has zero rows. This leads to better plans in some cases.