A Signal's counts run the same verdict query twice #348
Reference in New Issue
Block a user
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?
signal_rows (db.rs) counts a Signal's items and its unread with two copies of the same subquery over signal_verdicts, entries, subscriptions and entry_state. One pass with count(*) and sum(CASE WHEN NOT coalesce(st.read, false) THEN 1 ELSE 0 END) would do both. /api/signals is 33 ms, p95 70 ms; small.
Fixed in
c487873: one grouped subquery gives a Signal's items and unread (count and a sum), checked on SQLite and Postgres by the existing counts test. Deployed; /api/signals 22 ms.