<REFENTRY ID="SQL-EXPLAIN">
<REFMETA>
<REFENTRYTITLE>
EXPLAIN
</REFENTRYTITLE>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
</REFMETA>
<REFNAMEDIV>
<REFNAME>
EXPLAIN
</REFNAME>
<REFPURPOSE>
Shows statement execution details
</REFPURPOSE>

<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-01</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
EXPLAIN [ VERBOSE ] <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>        
</SYNOPSIS>

<REFSECT2 ID="R2-SQL-EXPLAIN-1">
<REFSECT2INFO>
<DATE>1998-09-01</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>

<VARIABLELIST>
<VARLISTENTRY>
<TERM>
VERBOSE
</TERM>
<LISTITEM>
<PARA>
Flag to show detailed query plan.

<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
Any <REPLACEABLE CLASS="PARAMETER">query</REPLACEABLE>.

</VARIABLELIST>

</REFSECT2>

<REFSECT2 ID="R2-SQL-EXPLAIN-2">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
</TITLE>
<PARA>

<VARIABLELIST>
<VARLISTENTRY>
<TERM>
NOTICE:  QUERY PLAN:
<replaceable>plan</replaceable>
</TERM>
<LISTITEM>
<PARA>
Explicit query plan from the <productname>Postgres</productname> backend.

<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<replaceable>status</replaceable>
</TERM>
<LISTITEM>
<PARA>
<VARLISTENTRY>
<TERM>
EXPLAIN
</TERM>
<LISTITEM>
<PARA>
Flag sent after query plan is shown.

</VARIABLELIST>
</VARIABLELIST>

</REFSECT2>
</REFSYNOPSISDIV>

<REFSECT1 ID="R1-SQL-EXPLAIN-1">
<REFSECT1INFO>
<DATE>1998-04-15</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
   This command outputs details about the supplied query.
   The default output is the computed query cost. 
   VERBOSE displays the full query plan and cost to your screen,
   and pretty-prints the plan to the postmaster log file.   

<REFSECT2 ID="R2-SQL-EXPLAIN-3">
<REFSECT2INFO>
<DATE>1998-04-15</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
There is only sparse documentation on the optimizer's use of cost
information in <productname>Postgres</productname>.
General information on cost estimation for query optimization
can be found in database textbooks.
Refer to the <citetitle>Programmer's Guide</citetitle>
in the chapters on indexes and the genetic query optimizer for
more information.

</REFSECT2>

<REFSECT1 ID="R1-SQL-EXPLAIN-2">
<TITLE>
Usage
</TITLE>
<PARA>
To show a query plan for a simple query:

<ProgramListing>
postgres=> explain select * from foo;
NOTICE:  QUERY PLAN:

Seq Scan on foo  (cost=0.00 size=0 width=4)

EXPLAIN
</ProgramListing>

</REFSECT1>

<REFSECT1 ID="R1-SQL-EXPLAIN-3">
<TITLE>
Compatibility
</TITLE>
<PARA>
</PARA>

<REFSECT2 ID="R2-SQL-EXPLAIN-4">
<REFSECT2INFO>
<DATE>1998-09-01</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
   There is no EXPLAIN statement defined in SQL92.
</REFENTRY>

<!--
<REPLACEABLE CLASS="PARAMETER">
</REPLACEABLE>
<ReturnValue></ReturnValue>
<PARA>
</PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>&bull;
</TERM>
<LISTITEM>
<PARA>
</PARA>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
<PARA>
</PARA>
-->
