Skip to content

[PERF]: Replace offset pagination with stable cursor pagination and query budgets #222

Description

@barry01-hash

Context

Payouts, applications, users, logs, and tickets will grow continuously. Offset pagination becomes slower at depth and can skip/duplicate results when rows are inserted between requests. Flexible filters also risk expensive unbounded queries.

Scope

  • Define opaque cursor contracts using a stable composite order such as (created_at, id).
  • Implement forward/backward cursor pagination for collection endpoints.
  • Add maximum page sizes, filter validation, and deterministic tie-breaking.
  • Review query plans and add evidence-based composite indexes for common role/status/date filters.
  • Avoid N+1 profile lookups and return only required fields.
  • Add representative-volume performance tests and query budgets.

Acceptance criteria

  • Concurrent inserts do not create duplicates or gaps while paging a fixed traversal.
  • Invalid/tampered cursors return a typed 400.
  • Deep-page latency stays within the documented budget on representative data.
  • EXPLAIN ANALYZE evidence accompanies new indexes.
  • Frontend pagination and TanStack Query cache behavior use the new contract.
  • A compatibility plan exists for current offset consumers.

Relevant areas

Payout find-all, bounty find-all, support ticket listing, user queries, filters and pagination components.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions