AdvancedAdvanced PostgreSQL
EXPLAIN ANALYZE: understand query execution
The query
SQL
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT
e.first_name,
e.last_name,
d.dept_name
FROM employees e
JOIN departments d ON e.dept_id = d.dept_id
WHERE e.salary > 80000;Note
“EXPLAIN ANALYZE runs the query and shows actual vs estimated row counts. BUFFERS shows cache hits. Key metrics: cost, rows, loops.