atproto relay in zig zlay.waow.tech
relay zig atproto

perf(pg): cache host_id, index account(host_id), short-circuit count (v0.0.3) master

tier 1 of the postgres workload handoff: cut the per-event query train and the new-account-admission seq scan. - host_id read-through/write-through cache (uid-keyed LRU). statement #2 (SELECT host_id ... every event, no cache) now hits the DB only on cache miss. setAccountHostId is the sole writer, so the cache stays coherent. - CREATE INDEX CONCURRENTLY on account(host_id): the per-host COUNT(*) on new-account admission was an 8.7M-row seq scan (no index existed). - getEffectiveAccountCount: CASE instead of COALESCE so the COUNT subquery only runs when no account_limit is set (COALESCE doesn't short-circuit the aggregate). regression test covers host_id cache coherence across set/update/clear/miss. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>


+225 -3
3 changed files