Area: Database Performance
Priority: P2 — Medium
Description
Offset pagination becomes slow at high pages because the database must scan and skip all preceding rows. Cursor-based pagination is O(log n) and stable for new data. Replace offset with cursors on hot endpoints.
Acceptance Criteria
Technical Notes
- Use
Buffer.from(JSON.stringify({t,i})).toString('base64url') for encoding
- Validate cursor shape; bad cursor → 400
- Limit + 1 query trick to detect nextCursor presence
Description
Offset pagination becomes slow at high pages because the database must scan and skip all preceding rows. Cursor-based pagination is O(log n) and stable for new data. Replace offset with cursors on hot endpoints.
Acceptance Criteria
cursorquery param toGET /tips/my/received,GET /tips/my/sent,GET /tips/wallet/:address{createdAt,id}tuplenextCursorandpreviousCursor(omitted when no more data)WHERE (createdAt, id) < (?, ?)for forward cursorsTechnical Notes
Buffer.from(JSON.stringify({t,i})).toString('base64url')for encoding