EXPLAIN

A command placed before a query that shows the plan the database would use instead of running it normally.

In more detail

In SQLite, EXPLAIN QUERY PLAN prints a short tree of SCAN and SEARCH steps. PostgreSQL's EXPLAIN shows estimated costs and row counts, and EXPLAIN ANALYZE actually runs the query and adds real row counts and timings. Measure first, then read the plan.

Example

EXPLAIN QUERY PLAN SELECT id, ordered_on FROM orders WHERE customer_id = 3 ORDER BY ordered_on;

Related terms

Taught in

References