Repository navigation
perf: speed up sparse row-stream reads (ANN 4.1-10.6x, indexed FTS 11x, scalar ~1x) - #11252
Merged
Xuanwo merged 1 commit intoNov 19, 2026
Merged
Conversation
Xuanwo
approved these changes
Nov 19, 2026
5 tasks done
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
LanceReadresolves 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
7bc65a9f6as the baseline. The table reports local warm-cache P50 ratios at 22,379 fragments as baseline time divided by optimized time.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.takecalls measured 0.99–1.06× at 22,379 fragments.Related work prunes fragment metadata for scalar-index scans. #8587
Change
_rowaddror address-encoded_rowidagainst the dataset manifest or the caller's fragment scope.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 andrelease-with-debugon an Apple M4 Pro.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
ScannerTop-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-ltofor both paths, with a benchmark-only switch to the7bc65a9f6metadata preparation path.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-ltobinary 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.
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.
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.
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
4e9620bac, 198 filtered-read, vector scan, and version-column tests passed.cargo fmt --all -- --checkandgit diff --checkpassed.