Skip to content

perf(filtered-read): prune non-candidate fragment metadata - #8587

Merged
BubbleCal merged 4 commits into
mainfrom
yang/perf-filtered-read-fragment-pruning
Aug 17, 2026
Merged

BubbleCal merged 4 commits into
mainfrom
yang/perf-filtered-read-fragment-pruning

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After a scalar index returns its row-ID mask, FilteredReadExec::get_or_create_plan_impl still loads deletion vectors, row counts, and row-ID metadata for every fragment before applying that mask. An exact index miss therefore performs an O(fragment count) metadata pass even though no fragment can contribute a row.

This is a follow-up to #7792. That PR removed the second all-fragment metadata load during stream construction; the first planning-time pass remained. Related to #4189, which tracks broader filtered-read planning costs.

Change

Use the index result's upper bound to decide whether a fragment can contribute before loading its full metadata:

  • skip every covered fragment for an exact empty allow-list;
  • use the fragment portion of address-style row IDs for direct pruning;
  • for non-empty stable row-ID masks, use each fragment's row-ID sequence to route candidates, then load deletion vectors and row counts only for candidate fragments;
  • carry the routed stable row-ID sequence and upper offset ranges into final planning, so exact and refined/at-most results do not map the same IDs twice;
  • cap retained stable-ID range payload at 16 MiB per plan and drain retained vectors fragment-by-fragment; over-budget fragments reuse the loaded row-ID sequence but recompute ranges during final planning;
  • keep uncovered fragments unless only_indexed_fragments is enabled;
  • conservatively keep block-list upper bounds and every fragment needed to calculate a pre-filter scan range.

Candidate fragments still load and apply their deletion vectors, so stale deleted index hits remain excluded. Pruning uses the upper bound of refined index results to avoid false negatives.

Benchmark

Lower is better for every metric below.

Scenario / metric Baseline (e958adfdf) This PR (150e000f0) Benefit
Exact-empty plan latency 1,630.20 ms/query 5.14 ms/query 316.9x speedup
Indexed zero-hit query latency 2,067.66 ms/query 84.73 ms/query 24.4x speedup
Indexed one-hit query latency 2,081.91 ms/query 163.69 ms/query 12.7x speedup
Exact-empty plan S3 reads 2,600 reads/query 0 reads/query 2,600 reads/query eliminated
Indexed zero-hit S3 reads 2,603 reads/query 3 reads/query 867.7x fewer reads
Indexed one-hit S3 reads 2,606 reads/query 7 reads/query 372.3x fewer reads

The review follow-up also measures cache-hot dense stable-row-ID planning, where all 5,200 physical row IDs route to all 2,600 fragments:

Scenario / metric Before follow-up (824551d44) This PR (150e000f0) Benefit
Dense stable-ID plan latency 9.17 ms/plan 7.86 ms/plan 1.17x speedup

The main-branch control was 7.13 ms/plan. The current implementation is 0.72 ms/plan (1.10x) above that control because it performs the stable-ID routing pass needed for pruning, but it no longer repeats the same mapping during final planning. All cache-hot measured plans performed 0 S3 reads.

Environment and methodology:

  • AWS m7i.4xlarge in us-east-1a, reading S3 in the same region.
  • One dataset with 2,600 stable-row-ID fragments, 2 rows per fragment, one real deletion vector per fragment, 14 payload columns, and BTree indices on org_id and repo_id.
  • Separate main, pre-follow-up, and current PR binaries built with Rust 1.97.1, release-with-debug, --no-default-features --features aws; their SHA256 hashes were checked before measurement.
  • Three serialized trials per case; base/PR order alternated by trial. Each trial used a new process and fresh Lance Session; the table reports medians.
  • Dataset-open time and I/O were excluded. Query/planning I/O uses incremental IOTracker statistics after open.
  • The dense case used three processes per revision. Each process ran one excluded S3 warm-up plan followed by 21 measured plans; the table reports the median of the three process medians. Index-result serialization and exec construction were outside the timed region.
  • This measures the metadata path against real S3, not the Plan Executor persistent-disk cache.

Measured bytes followed the same pattern: exact-empty planning dropped from 1,814,800 B/query to 0 B/query; the zero-hit query dropped from 1,882,874 B/query to 68,074 B/query; the one-hit query dropped from 1,965,927 B/query to 151,825 B/query.

Correctness and limitations

The regression coverage includes stable and address-style row IDs, exact-empty and sparse non-empty masks, refined upper bounds, partially indexed datasets, and only_indexed_fragments behavior. A deterministic dense stable-ID test counts mask_to_offset_ranges spans: four candidate fragments must produce exactly four mappings; the pre-follow-up implementation produced eight. A separate boundary test verifies that retained range payload cannot exceed the per-plan budget.

For a non-empty stable row-ID mask, this change still visits each covered fragment's row-ID sequence to discover candidate fragments. The benchmark fixture stores those sequences inline, so it removes the S3 deletion-vector/row-count reads but not the O(fragment count) routing walk. Datasets with external row-ID metadata can still perform O(fragment count) row-ID metadata reads. Eliminating that remaining cost requires carrying physical candidate-fragment information from scalar-index execution or persisted row-ID routing metadata.

Validation

  • cargo fmt --all
  • cargo test -p lance io::exec::filtered_read::tests -- --test-threads=1 (75 passed)
  • cargo clippy --all --tests --benches -- -D warnings
  • RUSTFLAGS='-D warnings' cargo +nightly-2026-07-13 check -p lance --tests
  • AWS S3 benchmark described above

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 17, 2026
@lance-gatekeeper lance-gatekeeper Bot removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 17, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 17, 2026
@BubbleCal

Copy link
Copy Markdown
Contributor Author

Addressed in 4e4207f. Stable-ID routing now carries the loaded RowIdSequence and computed upper offset ranges into LoadedFragment; Exact and Refined/AtMost planning reuse them, while AtLeast still maps its lower bound once. I added a deterministic regression that counts mask_to_offset_ranges spans (4 candidate fragments produce 4 calls; the previous head produced 8). On the 2,600-fragment cache-hot dense workload, median plan latency improved from 8.26 ms at 824551d to 7.15 ms at the current head (1.15x); the main control was 6.40 ms and the measured phase performed 0 S3 reads. The PR body now includes the methodology and exact-current-head S3 results.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 17, 2026
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lance-gatekeeper lance-gatekeeper Bot removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Aug 17, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 17, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 17, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The re-requested revision preserves the bounded stable-ID routing budget with a standard compare-exchange loop. It removes the nightly atomic API warning without changing candidate pruning, the 16 MiB retention bound, or fallback recomputation.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 17, 2026
@BubbleCal
BubbleCal merged commit f177fae into main Aug 17, 2026
62 of 65 checks passed
@BubbleCal
BubbleCal deleted the yang/perf-filtered-read-fragment-pruning branch August 17, 2026 17:50
zehiko pushed a commit to rerun-io/lance that referenced this pull request Nov 16, 2026
…mat#8587)

After a scalar index returns its row-ID mask,
`FilteredReadExec::get_or_create_plan_impl` still loads deletion
vectors, row counts, and row-ID metadata for every fragment before
applying that mask. An exact index miss therefore performs an O(fragment
count) metadata pass even though no fragment can contribute a row.

This is a follow-up to lance-format#7792. That PR removed the second all-fragment
metadata load during stream construction; the first planning-time pass
remained. Related to lance-format#4189, which tracks broader filtered-read planning
costs.

Use the index result's upper bound to decide whether a fragment can
contribute before loading its full metadata:

- skip every covered fragment for an exact empty allow-list;
- use the fragment portion of address-style row IDs for direct pruning;
- for non-empty stable row-ID masks, use each fragment's row-ID sequence
to route candidates, then load deletion vectors and row counts only for
candidate fragments;
- carry the routed stable row-ID sequence and upper offset ranges into
final planning, so exact and refined/at-most results do not map the same
IDs twice;
- cap retained stable-ID range payload at 16 MiB per plan and drain
retained vectors fragment-by-fragment; over-budget fragments reuse the
loaded row-ID sequence but recompute ranges during final planning;
- keep uncovered fragments unless `only_indexed_fragments` is enabled;
- conservatively keep block-list upper bounds and every fragment needed
to calculate a pre-filter scan range.

Candidate fragments still load and apply their deletion vectors, so
stale deleted index hits remain excluded. Pruning uses the upper bound
of refined index results to avoid false negatives.

Lower is better for every metric below.

| Scenario / metric | Baseline (`e958adfdf`) | This PR (`150e000f0`) |
Benefit |
| --- | ---: | ---: | ---: |
| Exact-empty plan latency | 1,630.20 ms/query | 5.14 ms/query | 316.9x
speedup |
| Indexed zero-hit query latency | 2,067.66 ms/query | 84.73 ms/query |
24.4x speedup |
| Indexed one-hit query latency | 2,081.91 ms/query | 163.69 ms/query |
12.7x speedup |
| Exact-empty plan S3 reads | 2,600 reads/query | 0 reads/query | 2,600
reads/query eliminated |
| Indexed zero-hit S3 reads | 2,603 reads/query | 3 reads/query | 867.7x
fewer reads |
| Indexed one-hit S3 reads | 2,606 reads/query | 7 reads/query | 372.3x
fewer reads |

The review follow-up also measures cache-hot dense stable-row-ID
planning, where all 5,200 physical row IDs route to all 2,600 fragments:

| Scenario / metric | Before follow-up (`824551d44`) | This PR
(`150e000f0`) | Benefit |
| --- | ---: | ---: | ---: |
| Dense stable-ID plan latency | 9.17 ms/plan | 7.86 ms/plan | 1.17x
speedup |

The main-branch control was 7.13 ms/plan. The current implementation is
0.72 ms/plan (1.10x) above that control because it performs the
stable-ID routing pass needed for pruning, but it no longer repeats the
same mapping during final planning. All cache-hot measured plans
performed 0 S3 reads.

Environment and methodology:

- AWS `m7i.4xlarge` in `us-east-1a`, reading S3 in the same region.
- One dataset with 2,600 stable-row-ID fragments, 2 rows per fragment,
one real deletion vector per fragment, 14 payload columns, and BTree
indices on `org_id` and `repo_id`.
- Separate main, pre-follow-up, and current PR binaries built with Rust
1.97.1, `release-with-debug`, `--no-default-features --features aws`;
their SHA256 hashes were checked before measurement.
- Three serialized trials per case; base/PR order alternated by trial.
Each trial used a new process and fresh Lance `Session`; the table
reports medians.
- Dataset-open time and I/O were excluded. Query/planning I/O uses
incremental `IOTracker` statistics after open.
- The dense case used three processes per revision. Each process ran one
excluded S3 warm-up plan followed by 21 measured plans; the table
reports the median of the three process medians. Index-result
serialization and exec construction were outside the timed region.
- This measures the metadata path against real S3, not the Plan Executor
persistent-disk cache.

Measured bytes followed the same pattern: exact-empty planning dropped
from 1,814,800 B/query to 0 B/query; the zero-hit query dropped from
1,882,874 B/query to 68,074 B/query; the one-hit query dropped from
1,965,927 B/query to 151,825 B/query.

The regression coverage includes stable and address-style row IDs,
exact-empty and sparse non-empty masks, refined upper bounds, partially
indexed datasets, and `only_indexed_fragments` behavior. A deterministic
dense stable-ID test counts `mask_to_offset_ranges` spans: four
candidate fragments must produce exactly four mappings; the
pre-follow-up implementation produced eight. A separate boundary test
verifies that retained range payload cannot exceed the per-plan budget.

For a non-empty stable row-ID mask, this change still visits each
covered fragment's row-ID sequence to discover candidate fragments. The
benchmark fixture stores those sequences inline, so it removes the S3
deletion-vector/row-count reads but not the O(fragment count) routing
walk. Datasets with external row-ID metadata can still perform
O(fragment count) row-ID metadata reads. Eliminating that remaining cost
requires carrying physical candidate-fragment information from
scalar-index execution or persisted row-ID routing metadata.

- `cargo fmt --all`
- `cargo test -p lance io::exec::filtered_read::tests --
--test-threads=1` (75 passed)
- `cargo clippy --all --tests --benches -- -D warnings`
- `RUSTFLAGS='-D warnings' cargo +nightly-2026-07-13 check -p lance
--tests`
- AWS S3 benchmark described above

(cherry picked from commit f177fae)
zehiko added a commit to rerun-io/lance that referenced this pull request Nov 17, 2026
Xuanwo pushed a commit that referenced this pull request Nov 19, 2026
…x, scalar ~1x) (#11252)

## Summary

`LanceRead` resolves physical row addresses first and prepares only
candidate fragments. This reduces the cost of sparse reads for vector
refinement, final projection, and full-text search.

The measurements use upstream `7bc65a9f6` as the baseline. The table
reports local warm-cache P50 ratios at 22,379 fragments as baseline time
divided by optimized time.

| Workload | Query P50 ratio | Row-stream P50 ratio |
| --- | ---: | ---: |
| Fixed-address read of 10 rows | 46.23× with planning | 47.66×
execution only |
| Indexed ANN with exact refinement | 5.41–10.56× | 19.77–33.45× |
| Indexed ANN without refinement | 4.09–7.27× | 18.54–30.75× |
| Indexed FTS, address-encoded row IDs | 11.03–11.20× | 43.27–44.18× |
| Unindexed exact vector search | 0.90–1.03× | 26.27–26.52× |
| Unindexed filter with late projection | 1.01–1.04× | 38.05–44.58× |
| Unindexed FTS | 0.93–1.09× | 37.38–50.36× |

At 6,525 fragments, indexed ANN query P50 improved 2.85–4.89× with
refinement and 2.89–4.18× for ANN-only. Full projection scans, BTree
mask reads, and direct `Dataset.take` calls measured 0.99–1.06× at
22,379 fragments.

Related work prunes fragment metadata for scalar-index scans.
[#8587](#8587)

## Change

- Resolve the fragment IDs in `_rowaddr` or address-encoded `_rowid`
against the dataset manifest or the caller's fragment scope.
- Apply any physical row selection before loading candidate fragment
metadata. Schedule reads from the fragments that have live rows in the
resulting batch plan.
- Preserve the caller's fragment scope and restore input row order and
duplicates when attaching the fetched columns.

## Benchmark

### Fixed-address row-stream read

The baseline is `7bc65a9f6`. A warm in-memory fixture returns the same
10 rows from the same physical files at every snapshot size. The table
reports execution-only P50 over 61 measured queries per case, after
eight warmups. Both versions use Rust 1.98.1 and `release-with-debug` on
an Apple M4 Pro.

| Visible fragments | Baseline P50 | Optimized P50 |
| ---: | ---: | ---: |
| 10 | 0.172 ms | 0.157 ms |
| 1,000 | 0.430 ms | 0.156 ms |
| 6,525 | 2.242 ms | 0.156 ms |
| 22,379 | 7.530 ms | 0.158 ms |

On the same 22,379-fragment snapshot with an explicit fragment scope,
P50 including construction of the read plan decreases from 7.554 ms to
0.592 ms.

### Indexed search with refinement and full projection

Run a normal `Scanner` Top-10 query with full projection against
snapshots fully covered by IVF_FLAT. The fixture uses 16-dimensional L2
vectors, four fixed centroids, one probe, and a refine factor of two.
Each A/B pair uses the same query, data files, and index. The plan
includes ANN, exact refinement, and two row-stream reads in both
variants.

The timer starts at scanner construction and ends when the full result
batch is available. The dataset handle and cache are warm. Each variant
has 101 measured queries per size after eight warmups. A/B order
alternates within one Apple M4 Pro process. The benchmark binary uses
Rust 1.98.1 and `release-no-lto` for both paths, with a benchmark-only
switch to the `7bc65a9f6` metadata preparation path.

| Visible fragments | Baseline P50 | Optimized P50 | P50 speedup |
Baseline P95 | Optimized P95 |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 10 | 0.972 ms | 1.026 ms | 0.95x | 1.168 ms | 1.377 ms |
| 1,000 | 1.586 ms | 0.958 ms | 1.66x | 1.902 ms | 1.214 ms |
| 6,525 | 5.814 ms | 1.213 ms | 4.79x | 6.491 ms | 1.512 ms |
| 22,379 | 19.484 ms | 2.058 ms | 9.47x | 21.253 ms | 2.424 ms |

An independent repeat at 22,379 fragments yielded 21.863 ms to 2.476 ms
P50 (8.83x) and 24.575 ms to 3.605 ms P95.

### Vector indices and other read paths

The matrix uses warm in-memory snapshots with 6,525 and 22,379
fragments, identical inputs within each A/B pair, and the same local
`release-no-lto` binary per driver. It covers all eight single-vector
index families on a 16-dimensional L2 fixture, with and without exact
refinement, plus unindexed exact vector search. Each indexed case has 51
samples per arm after eight warmups. The unindexed vector cases have 11
samples per arm.

A row-stream sample measures the batch's own planning, reading,
attachment and materialization after its input arrives. It excludes work
in the child plan. The non-vector row-stream column sums the recorded
batch durations for a query. A dash indicates that the plan uses a
different read path.

#### Indexed vector search at 22,379 fragments

All durations are milliseconds and use baseline → optimized.

| Index | Refined E2E P50 | Refined E2E P95 | Refine read P50 | Final
read P50 | ANN-only E2E P50 | ANN-only final read P50 |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| IVF_FLAT | 21.924 → 3.001 (7.31×) | 28.678 → 9.687 | 8.618 → 0.313 |
8.677 → 0.293 | 11.697 → 1.926 (6.07×) | 8.947 → 0.369 |
| IVF_PQ | 21.428 → 2.561 (8.37×) | 28.319 → 9.472 | 8.762 → 0.279 |
8.711 → 0.273 | 13.068 → 2.884 (4.53×) | 9.903 → 0.534 |
| IVF_SQ | 23.281 → 3.070 (7.58×) | 32.683 → 10.059 | 9.156 → 0.347 |
9.165 → 0.312 | 11.239 → 1.742 (6.45×) | 8.766 → 0.330 |
| IVF_RQ | 22.691 → 2.804 (8.09×) | 26.411 → 10.136 | 9.042 → 0.306 |
8.992 → 0.273 | 11.252 → 1.784 (6.31×) | 8.743 → 0.336 |
| IVF_HNSW_FLAT | 21.210 → 2.698 (7.86×) | 42.308 → 5.527 | 8.713 →
0.334 | 8.750 → 0.280 | 11.737 → 2.129 (5.51×) | 8.951 → 0.453 |
| IVF_HNSW_PQ | 26.593 → 4.919 (5.41×) | 69.659 → 19.037 | 10.588 →
0.591 | 10.336 → 0.452 | 10.300 → 1.417 (7.27×) | 8.025 → 0.261 |
| IVF_HNSW_SQ | 18.968 → 1.797 (10.56×) | 19.879 → 2.169 | 7.847 → 0.238
| 7.821 → 0.219 | 10.908 → 1.672 (6.52×) | 8.430 → 0.343 |
| IVF_HNSW_RQ | 21.989 → 2.439 (9.02×) | 23.048 → 3.002 | 8.928 → 0.284
| 8.804 → 0.270 | 13.789 → 3.371 (4.09×) | 9.323 → 0.499 |

At 6,525 fragments, refined indexed E2E improves by 2.85–4.89x and
combined row-stream work improves by 5.86–9.83x across the eight
indices. Unindexed exact vector search measures 263.685 → 189.732 ms E2E
and 2.774 → 0.322 ms in the final row stream.

At 22,379 fragments, refined indexed E2E improves by 5.41–10.56x and
combined row-stream work improves by 19.77–33.45x across the eight
indices. Unindexed exact vector search measures 706.399 → 781.230 ms E2E
and 8.806 → 0.332 ms in the final row stream.

#### Non-vector reads

Narrow cases use 41 samples per arm and scan-heavy cases use 11. The
main table uses 22,379 fragments. The legacy V1 control uses 6,525
fragments. All durations are milliseconds and use baseline → optimized.

| Workload | Row-stream nodes | E2E P50 | E2E P95 | Row-stream batch
work P50 |
| --- | ---: | ---: | ---: | ---: |
| Metadata count | 0 | 0.042 → 0.042 (1.00×) | 0.043 → 0.043 | — |
| Full projection scan | 0 | 373.030 → 350.834 (1.06×) | 867.203 →
672.416 | — |
| Scan LIMIT 10 | 0 | 0.536 → 0.652 (0.82×) | 1.093 → 1.186 | — |
| Scanner physical selection | 0 | 1.341 → 2.140 (0.63×) | 6.507 → 5.538
| — |
| Dataset take by offset | 0 | 1.811 → 1.801 (1.01×) | 5.609 → 6.114 | —
|
| Dataset take by row ID | 0 | 0.215 → 0.217 (0.99×) | 2.522 → 5.188 | —
|
| Dataset take by address | 0 | 0.211 → 0.214 (0.99×) | 0.738 → 0.575 |
— |
| BTree filter and projection | 0 | 6.598 → 6.622 (1.00×) | 7.417 →
7.442 | — |
| BTree filter with ordered limit | 0 | 7.972 → 7.905 (1.01×) | 8.769 →
9.103 | — |
| Unindexed filter with early projection | 0 | 429.418 → 418.155 (1.03×)
| 938.078 → 923.244 | — |
| Unindexed filter with late projection | 1 | 288.818 → 279.046 (1.04×)
| 1355.332 → 398.143 | 7.712 → 0.173 |
| Scanner ORDER BY LIMIT | 0 | 270.030 → 276.054 (0.98×) | 283.843 →
285.086 | — |
| Indexed FTS, address-encoded row IDs | 2 | 18.854 → 1.709 (11.03×) |
19.466 → 2.002 | 15.728 → 0.356 |
| Unindexed FTS with ordered projection | 2 | 286.432 → 263.600 (1.09×)
| 311.808 → 295.216 | 15.107 → 0.300 |
| Indexed FTS control, stable logical row IDs | 2 | 37.561 → 36.377
(1.03×) | 39.068 → 37.834 | 34.198 → 33.316 |
| Indexed FTS, legacy V1 TakeExec | 0 | 0.637 → 0.644 (0.99×) | 0.686 →
0.686 | — |

#### Independent scan and FTS repeat

At 22,379 fragments, the independent exact vector scan repeat measured
545.051 → 526.808 ms E2E and 8.907 → 0.339 ms in the final row stream.
The two trials show consistent savings in the row stream. End-to-end
scan timings vary between trials.

The repeat below reports P50 in milliseconds at 22,379 fragments. The
legacy V1 control uses 6,525 fragments. The row-stream labels identify
the columns fetched by each operator.

| Workload | E2E | Fetch id | Fetch payload | Combined row stream |
| --- | ---: | ---: | ---: | ---: |
| Full projection scan | 354.774 → 352.154 | — | — | — |
| Scanner physical selection | 0.523 → 0.537 | — | — | — |
| Unindexed filter with late projection | 354.312 → 351.860 | — | 9.133
→ 0.240 | 9.133 → 0.240 |
| Indexed FTS, address-encoded row IDs | 21.166 → 1.889 | 8.738 → 0.218
| 8.732 → 0.190 | 17.567 → 0.406 |
| Unindexed FTS | 352.464 → 380.723 | 8.509 → 0.256 | 8.364 → 0.188 |
16.857 → 0.451 |
| Indexed FTS control, stable logical row IDs | 41.458 → 40.194 | 18.719
→ 18.401 | 18.897 → 18.175 | 37.677 → 36.631 |
| Indexed FTS, legacy V1 TakeExec | 0.778 → 0.828 | — | — | — |

Indexed FTS with address-encoded row IDs measured an 11.03–11.20×
end-to-end P50 speedup. The separate stable logical row ID control uses
row-ID sequences to resolve addresses and measured about 1.03×. For
scan-heavy cases, saving several milliseconds in row-stream reads is a
small part of the total query time. Plain scans, BTree mask reads,
physical selections and the direct take APIs use other execution paths.

## Correctness and limitations

The optimization applies to physical addresses. Streams keyed by stable
logical row IDs resolve them through the dataset's row-ID sequences. An
explicit fragment scope is indexed once when the row-stream plan is
constructed. Fragment routing runs per batch. The benchmarks measure
sparse Top-10 queries one at a time on an in-memory store.

The new regression cases keep an unrequested fragment visible while
making its metadata unreadable. They cover physical addresses,
address-encoded row IDs, physical addresses on a stable-ID table, and an
explicit fragment scope.

## Validation

- After rebasing onto upstream `4e9620bac`, 198 filtered-read, vector
scan, and version-column tests passed.
- `cargo fmt --all -- --check` and `git diff --check` passed.
- The standalone regression checks passed in three key configurations.
They checked output order, repeated keys, and omission of stale keys
while an unrelated fragment's metadata was unreadable.
- The fixed-address benchmark checked every returned row and payload in
both variants.
- Both indexed query trials verified the complete output, row order,
payloads, vectors, and exact distances against the deterministic fixture
and between paths.
- The read matrix validated identical A/B plans where the Scanner
exposes a plan, and identical returned results for all workload pairs.
Vector tests also checked recall at 10 and verified per-stage row-stream
sample counts.

Co-authored-by: xiaguanglei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

K-approved Latest Gatekeeper recommendation permits acceptance. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants