Skip to content

Preserve exact PostgreSQL top-N ordering - #43

Merged
whilo merged 7 commits into
mainfrom
codex/secondary-performance
Aug 31, 2026
Merged

whilo merged 7 commits into
mainfrom
codex/secondary-performance

Conversation

@whilo

@whilo whilo commented Aug 30, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve full int64 precision in top-N order keys
  • keep PostgreSQL DESC NULL ordering in fallback sorts
  • push exact inclusive/exclusive order-key ranges into top-N
  • avoid repeatedly sorting discarded prefixes for bounded OFFSET queries

Motivation

The pg-datahike secondary workload exposed correctness issues at int64 boundaries and a deep-OFFSET amplification: OFFSET 50000 repeatedly sorted the same generation and took about 10.5 seconds. Requesting the exact bounded prefix once reduces that case to about 0.32 seconds. This remains O(offset); keyset continuations are separate follow-up work.

Validation

  • clj -M:ffix
  • clj -M:test
  • 1451 tests, 5898 assertions, 0 failures/errors

whilo added 7 commits August 29, 2026 12:26
Signed-off-by: Christian Weilbach <christian@weilbach.name>
Signed-off-by: Christian Weilbach <christian@weilbach.name>
Signed-off-by: Christian Weilbach <christian@weilbach.name>
Signed-off-by: Christian Weilbach <christian@weilbach.name>
Signed-off-by: Christian Weilbach <christian@weilbach.name>
Signed-off-by: Christian Weilbach <christian@weilbach.name>
Signed-off-by: Christian Weilbach <christian@weilbach.name>
@whilo
whilo merged commit 91a4366 into main Aug 31, 2026
7 checks passed
@whilo
whilo deleted the codex/secondary-performance branch August 31, 2026 20:32
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