Skip to content

perf(btree): keep the built page lookup in the cached index state - #116

Merged
zehiko merged 3 commits into
release-10.0.0from
zeljko/r10-btree-lookup-cache
Nov 17, 2026
Merged

zehiko merged 3 commits into
release-10.0.0from
zeljko/r10-btree-lookup-cache

Conversation

@zehiko

@zehiko zehiko commented Nov 17, 2026

Copy link
Copy Markdown
Member

Why

Every cache hit on a btree index's BTreeIndexState rebuilt BTreeLookup from the lookup batch, walking every page to find null pages.
So each index open cost grew with the index: on a Metastore chunks table with 446 fragments, ~0.5 ms per open, paid by every scalar-index query and every index_statistics call.
Upstream main still does this.

What

BTreeIndexState holds the built Arc<BTreeLookup> instead of the lookup batch; it is built once when the state is loaded or deserialized, and reconstruct reuses it.
The serialized form is unchanged.

Testing

Agent

This PR was written by Claude Code (an LLM), at the request of the author.

🤖 Generated with Claude Code

A cache hit on BTreeIndexState rebuilt BTreeLookup from the lookup batch,
walking every page to find null pages, on every index open. That made each
open cost grow with the index size: on a 446-fragment table it was ~0.5 ms
per open, paid by every scalar-index query and every index_statistics call.

The cached state now holds the built Arc<BTreeLookup>, so it is built once
when the state is loaded or deserialized and shared by every reconstruct.
The serialized form is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zehiko zehiko added the upstreamable change Belongs upstream, but is not there yet label Nov 17, 2026
@zehiko
zehiko marked this pull request as ready for review November 17, 2026 08:36
@zehiko
zehiko merged commit 00aa4bf into release-10.0.0 Nov 17, 2026
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index lance fork 10.0.0 Landed on the release-10.0.0 fork line performance upstreamable change Belongs upstream, but is not there yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants