A Signal's counts run the same verdict query twice #348

Closed
opened 2026-10-23 05:35:28 -07:00 by rays · 1 comment
Owner

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.

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.
rays added the enhancement label 2026-10-23 05:35:28 -07:00
Author
Owner

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.

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.
rays closed this issue 2026-10-23 08:35:33 -07:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#348