Skip to content

feat: (re-)enable timestamp+offset based pagination optimization#2145

Merged
chenba merged 2 commits intomasterfrom
feat/offset-pagination-opt-stor-473
Mar 26, 2026
Merged

feat: (re-)enable timestamp+offset based pagination optimization#2145
chenba merged 2 commits intomasterfrom
feat/offset-pagination-opt-stor-473

Conversation

@chenba
Copy link
Copy Markdown
Collaborator

@chenba chenba commented Mar 18, 2026

#53 enabled
#559 disabled

And this patch enables it for MySQL and Postgres but not Spanner.

Closes STOR-473

@chenba chenba force-pushed the feat/offset-pagination-opt-stor-473 branch 2 times, most recently from d86d3b1 to e4093a9 Compare March 18, 2026 23:51
@chenba chenba requested review from pjenvey and taddes March 19, 2026 01:21
Copy link
Copy Markdown
Member

@pjenvey pjenvey left a comment

Choose a reason for hiding this comment

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

Sorry for the delay this offset thing always confuses me

@@ -68,27 +68,16 @@ pub struct Offset {

impl Display for Offset {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't recall why we ended up/need a duplicate version of Offset here, maybe we can try killing the other one (in a separate issue)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

// issue559: Revert to previous sorting
/*
Sorting::Index => query.order(bso::id.desc()).order(bso::sortindex.desc()),
Sorting::Newest | Sorting::None => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a subtle bug, this small change here to make None act like Newest is I think at least one solution:

encode_next_offset returns the encoded offset for every type of sort except Index, including None. However that special offset isn't going to make much sense if we're not applying the timestamp above (in the Some(ts) _ => {} arm) -- and we probably also need to enforce some kind of ordering here for the pagination to make sense.

I thought we had a test somewhere for such a case but I guess not?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for catching that. I've made None behave like Newest.

#53 enabled
#559 disabled

And this patch enables it for MySQL and Postgres but not Spanner.
@chenba chenba force-pushed the feat/offset-pagination-opt-stor-473 branch from e4093a9 to 4023289 Compare March 26, 2026 16:37
Co-authored-by: Philip Jenvey <pjenvey@underboss.org>
@chenba chenba requested a review from pjenvey March 26, 2026 17:30
Copy link
Copy Markdown
Member

@pjenvey pjenvey left a comment

Choose a reason for hiding this comment

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

thanks Barry

@@ -68,27 +68,16 @@ pub struct Offset {

impl Display for Offset {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@chenba chenba merged commit c1d53b6 into master Mar 26, 2026
29 checks passed
@chenba chenba deleted the feat/offset-pagination-opt-stor-473 branch March 26, 2026 19:28
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.

2 participants