fix(indexer): index leaderboard sort columns + 60s TTL cache (#280) #741

Merged
Brouie merged 1 commit from qa/280-leaderboard-index-cache into main 2026-06-04 08:02:46 +00:00
Brouie commented 2026-06-04 03:20:55 +00:00 (Migrated from gitlab.com)

/traders/leaderboard sorts on volume_24h / volume_7d / volume_30d / total_trades, none of which were indexed → seq scan + top-N sort per unauthenticated request. Adds btree indexes (mirroring idx_traders_volume) and a 60s TTL response cache keyed by (sort_by, limit).

Verified live (QA Postgres, enable_seqscan=off to force index consideration on the tiny localnet table): plan goes from Seq Scan on traders + Sort (cost 1e10) → Index Scan using idx_traders_volume_24h with no Sort node (cost 12.16).

cargo check clean.

GitLab #280

`/traders/leaderboard` sorts on `volume_24h` / `volume_7d` / `volume_30d` / `total_trades`, none of which were indexed → seq scan + top-N sort per unauthenticated request. Adds btree indexes (mirroring `idx_traders_volume`) and a 60s TTL response cache keyed by `(sort_by, limit)`. Verified live (QA Postgres, `enable_seqscan=off` to force index consideration on the tiny localnet table): plan goes from `Seq Scan on traders` + `Sort` (cost 1e10) → `Index Scan using idx_traders_volume_24h` with no Sort node (cost 12.16). cargo check clean. GitLab #280
PlasticDigits (Migrated from gitlab.com) merged commit 4a95548d53 into main 2026-06-04 08:02:46 +00:00
PlasticDigits commented 2026-06-04 08:02:47 +00:00 (Migrated from gitlab.com)

mentioned in commit 4a95548d53

mentioned in commit 4a95548d53adce4af34fb00d0e2883564e2aba3f
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!741
No description provided.