Skip to content

[HARD][PERFORMANCE] Add cursor pagination, query budgets, indexes, and load-test gates #112

Description

@Obiajulu-gif

Overview

Harden ChainMove's data-access layer for growth by introducing consistent cursor pagination, query projections, index design, query budgets, and repeatable load testing for high-traffic dashboards and APIs.

Problem

Unbounded list queries, full-document reads, offset pagination, and missing compound indexes can become slow or expensive as users, transactions, investments, repayments, audit events, and activity records grow. Performance problems in finance APIs can also cause retries and duplicate user actions.

Scope

  • Inventory list/search/aggregation routes and document their expected access patterns.
  • Create a shared cursor-pagination contract with stable ordering and opaque signed/validated cursors.
  • Replace unbounded/large offset-based reads on priority routes.
  • Add explicit projections so passwords, KYC fields, metadata blobs, and unused fields are not loaded.
  • Design and document compound/partial/unique indexes for priority queries.
  • Add query explain/plan verification tooling using representative seeded data.
  • Define query budgets: maximum page size, execution time target, documents examined/returned ratio, and aggregation memory behavior.
  • Detect or prevent N+1 patterns in dashboard aggregation services.
  • Add cache boundaries only for safe, non-sensitive, clearly invalidated data.
  • Add k6/Artillery or equivalent load scenarios for transaction history, investor pools, repayment history, admin queues, and concurrent mutations.
  • Add CI or scheduled performance regression gates with practical thresholds.

Correctness requirements

  • Pagination must not skip or duplicate records when new records arrive between pages.
  • Cursors must reject tampering, wrong filter context, and expired/version-incompatible formats.
  • Authorization filters must be applied before pagination/counting.
  • Index changes need migration/rollout guidance.
  • Caching must never expose one user's data to another.

Test requirements

  • stable pagination with equal timestamps
  • inserts/deletes between page requests
  • cursor tampering and filter mismatch
  • page-size limits
  • authorization isolation
  • explain-plan assertions on seeded volume
  • N+1 regression check
  • load test with documented baseline and threshold

Acceptance criteria

  • Priority list routes use a consistent cursor contract.
  • Query projections and indexes match documented access patterns.
  • Representative queries stay within agreed budgets on seeded volume.
  • Pagination remains stable under concurrent inserts.
  • A repeatable load-test suite and baseline report are committed.
  • Performance regressions can be detected before deployment.
  • Lint, typecheck, tests, and build pass.

Difficulty

Hard

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions