-
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.
75582: opt: push limit into FK and self-joins in more cases r=mgartner a=mgartner #### opt: more accurate join multiplicity with FKs and self-joins When calculating join multiplicity in the presence of a foreign key, it was previously possible for the incorrect base table to be selected from the right expression, in the case that the right expression contained a self-join. The base table selected was incorrect because it did not contain the equality column from the join filter. This prevented the optimizer from determining that these joins preserve all rows from the left side of the join, which could prevent further optimization of a query. Now, only the right equality columns are passed to `checkForeignKeyCase` which ensures that the correct base table is selected. This is safe because `verifyFiltersAreValidEqualities` has already checked that the right equality columns are unfiltered in the right expression, so the same checks in `checkForeignKeyCase` are redundant. Release note (performance improvement): The optimizer better optimizes queries that include both foreign key joins and self-joins. #### opt: push limit into FK and self-joins in more cases Previously, a constant equality condition pushed into both sides of a foreign key join or self-join would prevent a limit from being pushed into the left side of the join. This was because the multiplicity builder could not determine that right filter would not remove any values also removed by the left filter. Without the join being labelled as left-preserving, the limit could not be pushed down. The multiplicity builder has been updated to recognize a few additional cases where left rows are preserved in foreign key joins and self-joins, allowing a limit to be pushed into the left side of the join. Currently, the multiplicity builder only recognizes cases where corresponding left and right columns are held equal to the same constant value. It is possible to extend this to more complex inequalities and boolean expressions, but this is left as a TODO for now. Fixes #74419 Release note (performance improvement): A LIMIT can now be pushed below a foreign key join or self-join in more cases, which may result in more efficient query plans. 75732: sql: pass statement request id to backend instead of statement fingerprint r=THardy98 a=THardy98 Previously, the frontend passed a statement fingerprint to the API to update the corresponding statement diagnostic request to an expired state. Now we pass the statement diagnostic ID directly. This resolves a SQL parsing error that occurs when a statement fingerprint contains single-quotes (i.e. when a statement fingerprint contains placeholders). Original PR with discussions: #74818 Resolves: #74226 Release note: None Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Thomas Hardy <[email protected]>
- Loading branch information
Showing
10 changed files
with
471 additions
and
53 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
Oops, something went wrong.