Skip to content

tp: search tables for pipeline WHERE instead of testing every row - #8298

Draft
LalitMaganti wants to merge 1 commit into
dev/lalitm/fold-orderfrom
dev/lalitm/pipe-scan-pushdown
Draft

LalitMaganti wants to merge 1 commit into
dev/lalitm/fold-orderfrom
dev/lalitm/pipe-scan-pushdown

Conversation

@LalitMaganti

@LalitMaganti LalitMaganti commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Why

A pipeline WHERE always scanned the whole table and tested each row,
even where the dataframe can find the rows directly: a binary search of
a sorted column such as id or ts, an index made with
CREATE PERFETTO INDEX, or nothing at all when a value can match no row.
The executor already has SortedScan, IndexScan and EmptySource for
this, but the pipeline planner never chose them.

Changes

  • SearchScans, a bound pass: for each WHERE directly on a scan, the
    conditions the scan can answer by searching move into the scan with
    their literals. A WHERE left with nothing to test is dropped
    (LogicalPlan::Bypass).
  • Scan::PlanSearch chooses as the dataframe's own planner does
    (SortedFilterStrategy, GetBestIndexForFilterSpecs), and
    Scan::Lower emits the SortedScan, IndexScan or EmptySource chosen.
  • A table's indexes are bound with its columns when a plan is loaded,
    so nothing new is serialized and an index made after the pipeline was
    written is still used.

Results are unchanged; only how the rows are found is.

Testing

  • New physical plan tests for sorted searches, index lookups and
    conditions no row can match, and a new diff test.
  • All trace processor unit tests and diff tests pass.

@LalitMaganti
LalitMaganti added this pull request to stack #8236 October 27, 2026 02:28
Base automatically changed from dev/lalitm/pipe-lower-where-limit to main October 29, 2026 18:19
@LalitMaganti
LalitMaganti force-pushed the dev/lalitm/pipe-scan-pushdown branch from 7e5a674 to 66b52d2 Compare October 29, 2026 19:26
@LalitMaganti
LalitMaganti removed this pull request from stack #8236 October 29, 2026 19:26
@LalitMaganti
LalitMaganti added this pull request to stack #8373 October 29, 2026 19:27
@LalitMaganti
LalitMaganti removed this pull request from stack #8373 October 29, 2026 19:28
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

@LalitMaganti
LalitMaganti force-pushed the dev/lalitm/pipe-scan-pushdown branch from 66b52d2 to 465554a Compare October 29, 2026 20:35
@LalitMaganti
LalitMaganti changed the base branch from main to dev/lalitm/fold-order October 29, 2026 20:35
@LalitMaganti
LalitMaganti added this pull request to stack #8386 October 29, 2026 20:35
A pipeline WHERE always scanned the whole table and tested each row,
even where the dataframe can find the rows directly: a binary search
of a sorted column such as `id` or `ts`, an index made with
CREATE PERFETTO INDEX, or nothing at all when a value can match no row.
The executor already has SortedScan, IndexScan and EmptySource for
this, but the pipeline planner never chose them.

A bound pass now moves into each scan a WHERE reads directly the
conditions the scan can answer by searching, choosing as the
dataframe's own planner does, and drops the WHERE if nothing is left
for it to test. Results are unchanged; only how the rows are found is.
The table's indexes are bound with its columns when a plan is loaded,
so nothing new is serialized and an index made after the pipeline was
written is still used.
@LalitMaganti
LalitMaganti force-pushed the dev/lalitm/pipe-scan-pushdown branch from 465554a to ad2a687 Compare October 29, 2026 20:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant