Repository navigation
Find the rows of a correlated subquery through an index for an expression of the outer columns - #445
Merged
Merged
Conversation
…sion of the outer columns
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A correlated subquery finds its rows through an index of a column when its condition is an
=of the column and a value of the outer query. Before, the value had to be a column of the outer query. Now it can be an expression of the columns of the outer query, ast2.thousand = t1.tenthous + 1. In the regression testcreate_index, one such query read 100 million rows and took 281 seconds.Changes
outer_exprreplacesouter_varinrupg-exec. It accepts a column of an outer query, a constant, a parameter, a cast, and a function that is not volatile and does not return a set, of such expressions. The expression must read at least one column of an outer query, so a plain query still scans its rows once.volatileinrupg-execis nowpub(crate).Known differences
None. The result of each query is the same, and the scan only reads fewer rows.
Tests
connection/outer_lookups.testis the output of PostgreSQL 19 for the same script in a new database. fmt, clippy, the workspace tests and the checks of xtask pass on server1.