You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The backend uses offset/limit pagination (?page=1&limit=10). At scale with thousands of campaigns, offset pagination becomes slow (full table scan + skip) and unreliable when records are inserted between pages (page drift). Cursor-based pagination is the scalable solution for production.
Summary
The backend uses offset/limit pagination (
?page=1&limit=10). At scale with thousands of campaigns, offset pagination becomes slow (full table scan + skip) and unreliable when records are inserted between pages (page drift). Cursor-based pagination is the scalable solution for production.Problem
In
backend/src/pagination.js:Issues:
SELECT * OFFSET Nrequires scanning and skipping N rows — O(N) costAcceptance Criteria
paginateItems(): if?cursor=is provided, use it instead of page/offset{ id, createdAt }base64-encoded so it's opaque to clientssqliteCampaignRepository.list():WHERE (createdAt, id) < (cursor.createdAt, cursor.id)withORDER BY createdAt DESC, id DESC LIMIT N+1{ items, nextCursor, hasMore }?cursor=is absentfrontend/src/components/Pagination.tsxto support cursor-mode (load more / infinite scroll option)backend/openapi.yamlReferences
backend/src/pagination.jsbackend/src/dal/sqliteCampaignRepository.jsfrontend/src/components/Pagination.tsx