mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
The author-only mask `kind IN (..) AND (kind NOT IN (private) OR pubkey = reader)` looked broad to the Postgres planner. When foreign private rows dominated the requested kinds, it walked the community's primary key backward, so a mixed read such as kinds [30300, 30078] scanned every row in the community: 1.4-1.8 s on a 2.45M-event community, against about 6 ms before the pushdown. With explicit kinds, emit `kind IN (public) OR (kind IN (private) AND pubkey = reader)` instead. Postgres can estimate and index each side, and the same reads now take 4-9 ms. Kindless reads keep the mask. Signed-off-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>