Why use a cursor instead of OFFSET for event search?
After this you can answer: Why use a cursor instead of OFFSET for event search?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”The search query fetches limit plus one rows, returns at most limit, and derives the next cursor from the last returned item. Its timestamp is formatted with microsecond precision because JavaScript Date would otherwise lose precision and could skip or repeat equal-time rows at a boundary.
The cursor includes asOf so moving wall-clock time does not change the upcoming filter between requests. A composite B-tree index supports the starts_at and ID order. Text search has its own trigram index; a cursor alone cannot make every filter fast.
Inserts, deletes and sort-key changes remain visible according to each query’s database view. A new row before the cursor may not appear in that traversal; a moved row can cross its boundary. For browsing events this can be acceptable. An audit export would need snapshot or version semantics and a clear retention policy instead.
Counter-questions
Section titled “Counter-questions”Why not order only by starts_at?
What if filters change between pages?
What do you measure before adding an index?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Search pagination, then inspect the rds-postgres piece →.
apps/api/src/queries/event-search.ts → searchRead this book online: https://book.theversehub.in/