Name

EXPLAIN — Explain the query plan

Syntax

image with no caption

Common Usage

EXPLAIN  INSERT ...;
EXPLAIN QUERY PLAN  SELECT ...;

Description

The EXPLAIN command offers insight into the internal database operation. Placing EXPLAIN in front of any SQL statement (other than itself) returns information about how SQLite would execute the given SQL statement. The SQL statement is not actually executed.

By itself, EXPLAIN will return a result set that describes the internal VDBE instruction sequence used to execute the provided SQL statement. A fair amount of knowledge is required to understand the output.

The full EXPLAIN QUERY PLAN variant will return a high-level summary of the query plan using English-like explanations of how the query will be assembled and if data will be accessed by a table scan or by index lookup. The EXPLAIN QUERY PLAN command is most useful for tuning SELECT statements and adjusting index placement.

These commands exist to help database administrators and developers understand how SQLite is processing SQL commands. They are designed for interactive tuning and adjustments. It is not recommended that applications programmatically query or utilize this data, as both the data and the format may change from one version of SQLite to the next.