The query text is your request; the plan is the database's chosen route. Read the plan before changing indexes.
Short answer: run EXPLAIN to see intended operations and EXPLAIN ANALYZE in a safe environment to see actual timing and rows. Large estimate errors, broad scans, expensive sorts, and repeated nested-loop work are the useful clues.
EXPLAIN ANALYZE
SELECT * FROM orders WHERE account_id = 42 ORDER BY created_at DESC LIMIT 50;
| Plan clue | Ask |
|---|---|
| Seq Scan | Is the filter selective enough for an index? |
| Rows mismatch | Are statistics stale or predicates correlated? |
| Sort | Can an index match filter plus order? |
EXPLAIN ANALYZEexecutes the query. Do not point it at a destructive statement on production merely to satisfy curiosity.
Measure, change one thing, and compare plans again.
Cover photo by Stanislav Kondratiev on Pexels.
