PostgreSQL Performance: Read the Query Plan
Thirty questions about diagnosing PostgreSQL performance from real EXPLAIN ANALYZE output. Covers index design, sequential scans, cardinality estimates, composite-index order, locking, transaction isolation, and pagination. Assume default settings and a recent PostgreSQL major version unless a question says otherwise.
Questions
- Not answered. In
cost=0.29..8.31, what do the two numbers mean? - Not answered. How many rows did the inner index scan return in total?
- Not answered. What does the large
Rows Removed by Filtercount tell you here? - Not answered. What does
lossy=8134mean in this bitmap heap scan, and how do you remove it? - Not answered. Why does an
Index Only ScanreportHeap Fetches: 214938? - Not answered. When is a sequential scan the right choice even though a usable index exists?
- Not answered. Which planner setting should you lower on SSD-backed storage to make index scans more competitive?
- Not answered. Which index serves this query best?
- Not answered. What does the
INCLUDE (total)clause actually buy you? - Not answered. Why does
WHERE name LIKE 'Ann%'ignore the plain B-tree index onname? - Not answered. Which index lets
WHERE lower(email) = $1use an index scan? - Not answered. When will the planner actually use this partial index?
- Not answered. How many rows will the planner estimate for
WHERE region_id = 7? - Not answered. Why is this row estimate 300 times too low, and what actually fixes it?
- Not answered. Which node in this plan should you fix first?
- Not answered. What can you conclude from
Sort Method: external merge Disk: 24800kB? - Not answered. What does
Batches: 8mean in a hash join? - Not answered. How many rows did this parallel scan read in total?
- Not answered. Why does page 5,000 of this listing take vastly longer than page 1?
- Not answered. Which
WHEREclause correctly fetches the page after the row('2026-03-01 10:00:00', 8412)? - Not answered. What does keyset pagination require to be both correct and fast?
- Not answered. What is true of
CREATE INDEX CONCURRENTLY? - Not answered. Why did every read on the table freeze the moment this migration started?
- Not answered. What does
FOR UPDATE SKIP LOCKEDdo for a job-queue worker? - Not answered. What harm does a session sitting
idle in transactionfor hours do to query performance? - Not answered. Why did adding one index slow down writes across the whole table?
- Not answered. What happens when you run
EXPLAIN ANALYZE DELETE FROM orders WHERE created_at < '2020-01-01';? - Not answered. What does
Buffers: shared hit=142 read=88231tell you? - Not answered. How do
READ COMMITTEDandREPEATABLE READdiffer when two transactions update the same row? - Not answered. Why is this query instant for most users and catastrophic for a few?