SQLAdvanced#performance

What is the difference between an execution plan and EXPLAIN ANALYZE?

EXPLAIN shows the plan the optimizer intends to use with estimated costs. EXPLAIN ANALYZE actually runs the query and reports real row counts and timings, exposing bad estimates.

Example
EXPLAIN ANALYZE
SELECT * FROM orders WHERE customer_id = 42;
-- compare 'rows=1000 estimated' vs 'actual rows=90000'

Related Questions

1
SQLAdvanced#performance

How do you optimise a slow SQL query?

Open
2
SQLAdvanced#scaling

What is partitioning and how does it differ from sharding?

Open
3
SQLIntermediate#architecture

OLTP vs OLAP?

Open