EXPLAIN

EXPLAIN returns a static query plan, which can be used to debug query plans.

To see an actively running query or statement, use SHOW_NODE_INFO instead.

See also SHOW_NODE_INFO, SHOW_SERVER_STATUS.

Permissions

The role must have the SELECT permissions for any tables referenced by the query.

Syntax

explain_statement ::=
    SELECT EXPLAIN(query_stmt)
    ;

Parameters

Parameter

Description

query_stmt

The select query to generate the plan for.

Notes

Use dollar-quoting to escape the query text

Examples

Generating a static query plan

t=> SELECT EXPLAIN($$SELECT DATEADD(hour,1,dt) FROM cool_dates$$);
   Select
      Specific (TTNative Gpu) ([email protected] := [email protected],
                               [email protected] := (pure_if [email protected] "0" (addHoursdt2dt [email protected] "1")))
    Table Scan
        public.cool_dates ("[email protected]", "[email protected]") []