-
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.
105214: opt: allow join-elimination rules to apply in more cases r=DrewKimball a=DrewKimball #### opt: allow join elimination rules to remap columns When it can be proven that a join does not add rows to or remove them from one of its inputs, the other input can often be removed, eliminating the join. However, this can only be done if the columns from the eliminated side are not needed. This patch allows the join elimination rules to remap columns from the eliminated side to the preserved side of the join, using the join's functional dependencies. For example: ``` CREATE TABLE xy (x INT PRIMARY KEY, y INT); CREATE TABLE fk (k INT PRIMARY KEY, v INT NOT NULL, FOREIGN KEY (v) REFERENCES xy (x)); SELECT x, k, v FROM fk INNER JOIN xy ON v = x; ``` In the example above, the join could not previously be eliminated because the `x` column is required in the output. Now, the `x` column is remapped to the equivalent `v` column, allowing the join to be removed. Fixes #102614 Release note (performance improvement): The optimizer can now eliminate joins in more cases. #### opt: infer equality filters for self joins When a table is joined to itself with an equality that forms a key over both join inputs, it is possible to infer equality filters between each pair of columns at the same ordinal position in the base table. This patch improves the logical props builder to infer these self-join equalities in a join's FuncDepSet. This improves the quality of information available to optimization rules, and in particular, join elimination rules. Informs #102614 Release note: None Co-authored-by: Drew Kimball <[email protected]>
- Loading branch information
Showing
32 changed files
with
918 additions
and
568 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.