SQL

EXPLAIN

CautionQuery plan

EXPLAIN ANALYZE <query>;

Inspect the query plan to find why it's slow (e.g. full scans).

Examples

  • EXPLAIN ANALYZE SELECT * FROM orders WHERE uid=1;Plan with real timings

Syntax

EXPLAIN [ANALYZE] <query>;

Before you run it

ANALYZE actually executes the query.

Used when you see

Slow database queries
2
Check the slow query's planFull scans and huge row estimates are the warnings.
See the whole flow →

Related commands

The same reference, with no signal at all

Every command and flow from this site, held on your device and searchable with no connection. Free to install, no ads.

Get it free on the App Store