It estimates the cost of candidate plans from statistics and picks the cheapest. EXPLAIN shows the chosen plan.
Query planner
The part of the database that chooses how to run a query.
It estimates the cost of candidate plans from statistics and picks the cheapest. EXPLAIN shows the chosen plan.