Cursor pagination for the audit log

Cursor pagination for the audit log

SH

audit log page 40 takes 6 seconds. offset pagination right

11:05

Offset, yes. Page 40 makes Postgres walk 40 pages of rows to throw away 39 of them, and it gets linearly worse. Keyset pagination reads the same number of rows for page 40 as for page 1:

queries/audit-page.sql

The (created_at, id) tuple is doing the work: created_at alone is not unique, so a tie at a page boundary either repeats a row or skips one.

11:06
SH

we lose jump-to-page

11:14

You do. Nobody jumps to page 40 of an audit log; they filter by date and actor. If a jump is genuinely needed, a date picker gets there in one request and reads better than a page number.

11:15

ReUI Chat can make mistakes. Check important info.