[Feature]: Scale #23
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem / use case
The admin list pages (/events, /incidents, /decisions, /audit, /signatures) use keyset pagination with server-side sorting and filtering. Every page render issues three PostgreSQL queries: the page fetch (
ORDER BY <col>, id LIMIT pageSize+1), aCOUNT(*)for the total, and a preceding-row count for the "Page N of M" indicator. At current data volumes these are cheap, but the events and audit tables ingest continuously, so query cost grows linearly with table size:events.occurred_at,audit_records.timestamp); others are not (decisions.created_at), and join-based sorts (events by source key, decisions by policy or classification) have no covering index.COUNT(*)and preceding count are O(table size) on every render, sorted or not. This is the dominant growth cost.Proposed solution
In order of preference:
(sort_col, id)indexes on the headings that real usage shows are clicked often. Each index taxes ingest writes, so add them based on observed slow queries rather than speculatively.pg_class.reltuples) for the unfiltered case, cap the display (for example "10,000+"), or add short-TTL in-process count caching withIMemoryCache(no new infrastructure).Alternatives considered