Index member_rights_applied, bound the intake claim, aggregate changelog stats

Performancekamo-shared-library
Shipped
August 21, 2026 at 12:20 AM UTC
Author
Kamo
Commit
00d2922

Three findings from an endpoint-by-endpoint audit, each measured against production rather than inferred. member_rights_applied declared no indexes at all while every finder on it filters by MEMBER_ID. At 10,524 rows a single member's rights lookup was a full sequential scan: Seq Scan on member_rights_applied (actual rows=192) Execution Time: 368.278 ms 368 ms to read one member's rights, on a table that grows with members x rights. One composite (member_id, the_right) serves the member-only finders and lets findByMemberAndRight resolve from the index. Deleting a lead-intake endpoint loaded every stored payload as an entity — raw request bodies included — and then deleted them one at a time. The busiest endpoint in production holds 6,842, so that was ~6 MB hydrated and 6,842 distributed writes inside one request. The line above it already deleted mappings in bulk; payloads now match. The intake job's claim was unbounded. It holds each payload's raw and flattened text for the whole run, so its memory was a function of how far behind it had fallen — exactly when it can least afford it, and the farm import put 14,520 payloads in that table. It now takes the oldest 500 per tick and drains a backlog across runs. Also adds grouped counts for the changelog, so /changelog/public/stats can stop hydrating 16,571 entities to build two small maps.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing