I learned about ksuid’s at work this week, and how amazingly clever they are.
They conveniently provide UUID-like uniqueness but with a timestamp component
for stupid simple ordering and cursor-based pagination.
Here’s a simple query that can be used to paginate over a table, via ksuid.
For the first page,
$1= ""
For the Nth page,
$1= last evaluated id from N-1th page
cursor-pagination.sql
This approach is directly inspired by DynamoDB’s LastEvaluatedKey
option on its query command.