Blog post: how moving one word can speed up a query 20–50x
Write and publish a blog post explaining the NOT EXISTS vs EXISTS partial index performance pattern. ## Summary On a soft-delete pattern, `NOT EXISTS (... AND deleted)` with a partial index on the minority (2% deleted rows) is 30–50x faster than `EXISTS (... AND NOT deleted)` with a partial index on the majority. Two compounding factors: 1. "Not found in index" skips the heap entirely — no heap fetch, no visibility check 2. Small partial index (22 MiB) stays warm in cache; large index (1,050 MiB) gets evicted ## Benchmark PG18, 50M rows, 13 GiB table, CCX33 (8 vCPU 32 GiB), cold cache: - 250 tag_ids: 22,574 ms vs 717 ms = 31x - 1,000 tag_ids: 63,750 ms vs 1,996 ms = 32x - Hot cache: 724 ms vs 161 ms = 4.5x Full raw results: https://gitlab.com/postgres-ai/postgresql-consulting/tests-and-benchmarks/-/issues/74 ## Credit Pattern first identified by Maxim Boguk on a 400 GiB production table (~50x speedup). MR: !885
issue