1998-09-05 08:02:57 +02:00
|
|
|
<REFENTRY ID="SQL-EXPLAIN">
|
|
|
|
<REFMETA>
|
|
|
|
<REFENTRYTITLE>
|
|
|
|
EXPLAIN
|
|
|
|
</REFENTRYTITLE>
|
|
|
|
<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
|
|
|
|
</REFMETA>
|
|
|
|
<REFNAMEDIV>
|
|
|
|
<REFNAME>
|
|
|
|
EXPLAIN
|
|
|
|
</REFNAME>
|
|
|
|
<REFPURPOSE>
|
1998-09-25 15:42:46 +02:00
|
|
|
Shows statement execution details
|
1998-09-05 08:02:57 +02:00
|
|
|
</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:
|
1998-09-25 15:42:46 +02:00
|
|
|
<replaceable>plan</replaceable>
|
1998-09-05 08:02:57 +02:00
|
|
|
</TERM>
|
|
|
|
<LISTITEM>
|
|
|
|
<PARA>
|
|
|
|
Explicit query plan from the <productname>Postgres</productname> backend.
|
|
|
|
|
1998-09-25 15:42:46 +02:00
|
|
|
<VARIABLELIST>
|
|
|
|
<VARLISTENTRY>
|
|
|
|
<TERM>
|
|
|
|
<replaceable>status</replaceable>
|
|
|
|
</TERM>
|
|
|
|
<LISTITEM>
|
|
|
|
<PARA>
|
1998-09-05 08:02:57 +02:00
|
|
|
<VARLISTENTRY>
|
|
|
|
<TERM>
|
|
|
|
EXPLAIN
|
|
|
|
</TERM>
|
|
|
|
<LISTITEM>
|
|
|
|
<PARA>
|
|
|
|
Flag sent after query plan is shown.
|
|
|
|
|
1998-09-25 15:42:46 +02:00
|
|
|
</VARIABLELIST>
|
1998-09-05 08:02:57 +02:00
|
|
|
</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.
|
|
|
|
|
|
|
|
<REFSECT2 ID="R2-SQL-EXPLAIN-3">
|
|
|
|
<REFSECT2INFO>
|
|
|
|
<DATE>1998-04-15</DATE>
|
|
|
|
</REFSECT2INFO>
|
|
|
|
<TITLE>
|
|
|
|
Notes
|
|
|
|
</TITLE>
|
|
|
|
<PARA>
|
1998-09-25 15:42:46 +02:00
|
|
|
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.
|
1998-09-05 08:02:57 +02:00
|
|
|
|
|
|
|
</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>•
|
|
|
|
</TERM>
|
|
|
|
<LISTITEM>
|
|
|
|
<PARA>
|
|
|
|
</PARA>
|
|
|
|
</LISTITEM>
|
|
|
|
</VARLISTENTRY>
|
|
|
|
</VARIABLELIST>
|
|
|
|
<PARA>
|
|
|
|
</PARA>
|
|
|
|
-->
|