Glossary · Databases

Query Execution Plan

A query execution plan is the step-by-step strategy a database chooses to run a query, showing scans, index use, join methods, and estimated costs.

Updated October 6, 2026

A query execution plan is the sequence of operations the database planner selects to answer a query, such as which indexes to use, in what order to join tables, and which join algorithms to apply.

Why it matters

The plan reveals why a query is slow. A full table scan on a big table, a join that processes millions of rows, or a sort that spills to disk all show up in it. Most databases expose it through EXPLAIN, and the ANALYZE variant also runs the query to report actual timings and row counts alongside the estimates.

Example

EXPLAIN SELECT * FROM orders WHERE customer_id = 42;

Index Scan using idx_orders_customer on orders
  Index Cond: (customer_id = 42)

A line reading "Seq Scan" on a large table instead would suggest a missing index.

Common mistakes

  • Reading estimates only. Large gaps between estimated and actual rows point to stale statistics.
  • Running EXPLAIN ANALYZE on a destructive statement, which really executes it.
  • Testing on tiny development data, where the planner picks different plans than in production.

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.