Skip to content

sstable, db: document SeekPrefixGE for sstable and level iters#5736

Merged
RaduBerinde merged 1 commit intocockroachdb:masterfrom
RaduBerinde:document-seek-prefix
Jan 21, 2026
Merged

sstable, db: document SeekPrefixGE for sstable and level iters#5736
RaduBerinde merged 1 commit intocockroachdb:masterfrom
RaduBerinde:document-seek-prefix

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

This is an attempt to document the current semantics as they are currently implemented.

Also see the discussions in #3845

I hope to be looking at a way to resolve some of these complexities, perhaps by adding more tombstone-related logic in the merging iterator (postponing seeks instead of seeking beyond the prefix just to enact a levelIter positioning suitable for a subsequent try-seek-using-next).

@RaduBerinde RaduBerinde requested a review from a team as a code owner January 20, 2026 20:22
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

:lgtm:

@sumeerbhola reviewed 2 files and all commit messages, and made 4 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jbowens and @RaduBerinde).


sstable/reader_iter_single_lvl.go line 874 at r1 (raw file):

// key is greater than or equal to the iterator's current position. When set,
// the iterator may optimize by scanning forward from its current position
// rather than performing a full seek. This optimization is automatically

nit: worth saying that the optimization is disabled by the callee (i.e., it ignores the flag in this case).


level_iter.go line 713 at r1 (raw file):

// The prefix argument is passed to each file's iterator for bloom filter
// checking. If a file's bloom filter indicates that prefix is not present, that
// file is skipped. The key argument is used for the actual seek positioning.

consider elaborating:
... is skipped, and the iterator moves to the next file if and only if the next file also can contain the prefix.


level_iter.go line 725 at r1 (raw file):

// higher level may cover all keys with prefix P1, requiring the merging
// iterator to seek past the tombstone to a key with prefix P3 > P1. In this
// case, the merging iterator calls SeekPrefixGE(P1, keyWithPrefixP3, flags).

this could clarify that keyWithPrefixP3 is the end key of the RANGEDEL.

This is an attempt to document the current semantics as they are
currently implemented.

Also see the discussions in cockroachdb#3845

I hope to be looking at a way to resolve some of these complexities,
perhaps by adding more tombstone-related logic in the merging iterator
(postponing seeks instead of seeking beyond the prefix just to enact a
levelIter positioning suitable for a subsequent try-seek-using-next).
Copy link
Copy Markdown
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

TFTR!

@jbowens let me know if there is anything to add. This still hurts my head haha

@RaduBerinde made 3 comments and resolved 1 discussion.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @jbowens and @sumeerbhola).


level_iter.go line 713 at r1 (raw file):

Previously, sumeerbhola wrote…

consider elaborating:
... is skipped, and the iterator moves to the next file if and only if the next file also can contain the prefix.

Done.


level_iter.go line 725 at r1 (raw file):

Previously, sumeerbhola wrote…

this could clarify that keyWithPrefixP3 is the end key of the RANGEDEL.

Reworded with a more specific example, PTAL

Copy link
Copy Markdown
Contributor

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

@jbowens reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @sumeerbhola).

@RaduBerinde
Copy link
Copy Markdown
Member Author

TFTRs!

@RaduBerinde RaduBerinde merged commit 678ab66 into cockroachdb:master Jan 21, 2026
9 checks passed
@RaduBerinde RaduBerinde deleted the document-seek-prefix branch January 22, 2026 00:03
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.

4 participants