Serve /api/v1/stats counts from realtime in-memory counters (closes #27)
check / check (push) Successful in 2m20s
check / check (push) Successful in 2m20s
The stats endpoints recomputed every count with a COUNT(*) over each table plus a MIN/MAX union scan on every request, which took the whole timeout and returned 500 once the database passed a few GiB. The row counts (ASNs, prefixes, peerings, peers, live routes) now live in memory: seeded once at startup and adjusted on each write as routes and records are inserted, updated and removed, so a read serves them with no scan and no timer. A live-route upsert is an UPDATE, then an INSERT only when no row matched, so its rows-affected count tells a new route from a re-announced one. Oldest/newest timestamps read one row from each end of the last_updated index, which also fixes the per-call scan warning. The distinct-prefix histogram stays a single indexed query. JSON shape of /api/v1/stats and the status page is unchanged. Model: opus-4-8
This commit is contained in:
@@ -23,6 +23,10 @@ runs make check on main.
|
||||
|
||||
# Completed Steps
|
||||
|
||||
- 2026-09-22: realtime in-memory database statistics: counts seeded at
|
||||
startup and adjusted on every write, oldest/newest route timestamps via
|
||||
index-end lookups; `/api/v1/stats` no longer scans the tables (closes
|
||||
#27)
|
||||
- 2026-07-07 Adopted scripts-to-rule-them-all: `script/` entrypoints,
|
||||
Makefile shims, README Entrypoints section
|
||||
- 2026-02-22: repo policy compliance: required policy files, .gitignore
|
||||
|
||||
Reference in New Issue
Block a user