EXPLAIN

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

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) (dateadd@null := dt@null,
                               dateadd@val := (pure_if dt@null "0" (addHoursdt2dt dt@val "1")))
    Table Scan
        public.cool_dates ("dt@null", "dt@val") []