Repository navigation
perf: hold the filter on a scan as its residual predicate - #398
Merged
Merged
Conversation
A filter right on a table scan becomes the scan's predicate. A chosen static index range leaves it just the residual, and a covered secondary index read skips the scan columns nothing references anymore, leaving them NULL. Column pruning marks the scans read by position above as pinned, so their columns are never skipped.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #398 +/- ##
==========================================
+ Coverage 93.01% 93.07% +0.05%
==========================================
Files 273 273
Lines 39012 39175 +163
==========================================
+ Hits 36286 36461 +175
+ Misses 2726 2714 -12
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
SeqScan and IndexScan check the scan's own predicate as they read rows, sharing one loop over their storage iterator, instead of wrapping the scan in a Filter executor.
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.
What problem does this PR solve?
A filter on a table scan was a separate
Filteroperator, so a scan had no notion of which filter was its residual predicate. When an index range eliminated the filter, the scan still decoded the columns only that filter had read.Issue link:
What is changed and how it works?
PushPredicateIntoScanturns the filter right on a scan into the scan'spredicate, which the scan evaluates itself. Other filters stay separate operators.EliminateIndexFilterreplaces a scan's predicate with the residual of the chosen static index range.SkipResidualFilterColumns, leaves NULL in a covered secondary index read the scan columns nothing references anymore (no operator above, and not the remaining predicate), so their index fields are skipped instead of decoded. Column pruning marks the scans read by position above (DML, the plan root, ...) aspinned; those are never skipped.PhysicalOption::filtered_rowskeeps its work at the rows it reads, so plan costs match the previousFilter -> SeqScan.PushLimitIntoScanno longer pushes a limit into a scan holding a predicate.TableScan t -> [...], Filter: (...).HashAggExecutorkeeps its group table as a field cleared on reset, keeping its capacity, and emits groups in insertion order.Code changes
Check List
Tests
Side effects
Note for reviewer
skip_residual_filter_columns_in_covered_index_readschecks the cover mapping and the rows when the range eliminates the filter, when a residual still reads a column, when the output reads every column, and that an UPDATE through the index keeps its rows intact.make clippy,make test,make test-sltandmake test-slt-sqlitepass. TPC-C shows no regression against perf: cover scans with primary keys and estimate key prefixes for TPC-C #397.