mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
perf(python): deduplicate sync query preparation (#5130)
## Summary Sync query execution rebuilt schema-derived state several times inside one call: for vector-column inference, blob projection validation, row-id preparation, async handoff, and result finalization. A plain point lookup paid five schema reads and five background-loop submissions per `to_arrow()`. This change prepares the schema and projected blob sources once per execution and reuses them through scan setup, result finalization, and the async handoff. Sync-prepared queries tell the async layer that blob row ids are already resolved; nothing is cached between executions, so a reused builder still observes schema changes. Plain scans and explicit vector columns no longer read the schema just to infer a vector column, and the dead vector conversion in `LanceVectorQueryBuilder.to_batches()` is removed. Non-lazy vector `to_arrow()` stays on its lazy materialization path, so reranking and snapshot merging run once before the aggregate blob conversion. Async behavior, namespace routing, fragments, timeouts, and public APIs are unchanged. A direct synchronous Rust terminal remains follow-up work. ## Benchmark Workload: 200,000 rows, 64 dimensions, BTREE on `id`, IVF_PQ on `vector`; 50 warmups + 500 calls per run; p50 of three runs. Baseline and candidate Python packages ran against the same `release-no-lto` extension built at `a2176f9b`; only package source differed. Local NVMe, single host. | Workload | Loop/schema per call before -> after | p50 before -> after | |---|---|---| | plain point lookup `to_arrow()` | 5 / 5 -> 2 / 1 | 6.06 / 6.08 / 5.67 ms -> 3.26 / 3.26 / 3.33 ms | | indexed vector `to_arrow()` | 5 / 5 -> 3 / 2 | 8.82 / 8.21 / 8.35 ms -> 6.40 / 6.55 / 6.60 ms | | plain point lookup `to_batches().read_all()` | 6 / 4 -> 4 / 1 | 6.88 / 7.25 / 6.94 ms -> 4.37 / 4.80 / 3.76 ms | `release-no-lto` is a local comparison build, not a release-profile number. The branch includes a merge of current main (`a2176f9b`, #5129); the affected blob, reranker, FTS, query, and namespace checks were rerun against the merged tree. Refs OSS-2867 (non-closing).
This commit is contained in:
@@ -120,7 +120,7 @@ def test_wal_hybrid_fuses_on_the_key_and_drops_it_again():
|
||||
with_row_ids=True,
|
||||
)
|
||||
results = builder._finish_hybrid_results(
|
||||
combined, blob_mode="lazy", blob_sources={}
|
||||
combined, blob_mode="lazy", blob_sources={}, schema=None
|
||||
)
|
||||
|
||||
assert "_rowid" not in results.column_names, "the surrogate is internal"
|
||||
|
||||
Reference in New Issue
Block a user