Skip to content

Search snapshot tables by level and key range - #227

Merged
greensky00 merged 1 commit into
masterfrom
junahn_pr3
Nov 11, 2026
Merged

greensky00 merged 1 commit into
masterfrom
junahn_pr3

Conversation

@greensky00

Copy link
Copy Markdown
Contributor
  • Snapshot lookups searched every table captured by the snapshot, so a point, nearest, or prefix lookup cost one ForestDB lookup per table. With a few hundred tables, it was 20-45x slower than before.

  • Keep the captured tables grouped by level, with level-1+ tables sorted by min key as in the manifest, and choose the candidate tables in the same way as TableManifest::getTables*():

    • Level-0: tables of the hash partition (point), or all (nearest).
    • Level-1+: the table containing the key, plus the neighbor table for nearest lookups, and all tables matching the prefix for prefix lookups.
  • Unlike the manifest, tables sharing the same min key (e.g., in the middle of in-place compaction) are all searched, and prevTableSearchRequired is captured when the snapshot is opened, since fixTable() may clear it later.

  • Point lookups still search all levels and choose the newest record, as the snapshot may have been captured in the middle of compaction.

* Snapshot lookups searched every table captured by the snapshot, so a
point, nearest, or prefix lookup cost one ForestDB lookup per table.
With a few hundred tables, it was 20-45x slower than before.

* Keep the captured tables grouped by level, with level-1+ tables sorted
by min key as in the manifest, and choose the candidate tables in the
same way as `TableManifest::getTables*()`:
  - Level-0: tables of the hash partition (point), or all (nearest).
  - Level-1+: the table containing the key, plus the neighbor table for
    nearest lookups, and all tables matching the prefix for prefix
    lookups.

* Unlike the manifest, tables sharing the same min key (e.g., in the
middle of in-place compaction) are all searched, and
`prevTableSearchRequired` is captured when the snapshot is opened,
since `fixTable()` may clear it later.

* Point lookups still search all levels and choose the newest record,
as the snapshot may have been captured in the middle of compaction.
@greensky00
greensky00 merged commit 6dc167b into master Nov 11, 2026
1 check passed
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