-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34801: sql: fix the subquery limit optimization r=knz a=knz Found this while investigating #32054. A while ago the HP was equipped with an optimization: when a subquery is planned for EXISTS or "max 1 row" (scalar context), a LIMIT is applied on its data source. This ensures that the data source does not fetch more rows than strictly necessary to determine the subquery result: - for EXISTS, only 0 or 1 row are needed to decide the boolean; - for scalar contexts, only 0, 1 or 2 rows are needed to decide the outcome 0 or 2 yield an error, only 1 gets a valid result. This optimization was temporarily broken for the scalar case when `max1row` was introduced (when local exec was subsumed by distsql), because the limit was remaining "on top" of `max1row` and not propagated down. This patch places it "under" so it gets propagated again. Release note (performance improvement): subqueries used with EXISTS or as a scalar value now avoid fetching more rows than needed to decide the outcome. Co-authored-by: Raphael 'kena' Poss <[email protected]>
- Loading branch information
Showing
12 changed files
with
176 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.