1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<!-- manual page source format generated by PolyglotMan v3.0.4, -->
<!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
<HTML>
<HEAD>
<TITLE>EXPLAIN(SQL) manual page</TITLE>
</HEAD>
<BODY>
<A HREF="sql.html">SQL Reference Contents</A>
<H2><A NAME="sect0" HREF="#toc0">NAME </A></H2>
explain - explains statement execution details
<H2><A NAME="sect1" HREF="#toc1">SYNOPSIS </A></H2>
<B>explain
[verbose] </B> query <BR>
<H2><A NAME="sect2" HREF="#toc2">DESCRIPTION </A></H2>
This command outputs details about the
supplied query. The default output is the computed query cost. <I>verbose
</I> displays the full query plan and cost. <P>
<H2><A NAME="sect3" HREF="#toc3">EXAMPLES </A></H2>
In the examples, the
table has a single column of float4. <B>cost </B> is the cost of scanning a base/join
relation, <B>size </B> is the expected number of tuples from a scan, <B>width </B> is
the length of a tuple. <P>
tgl=> explain select a from testg <BR>
NOTICE:QUERY
PLAN: <BR>
<P>
Seq Scan on test (cost=0.00 size=0 width=4) <BR>
<P>
EXPLAIN <BR>
tgl=> explain
verbose select sum(a) from test; <BR>
NOTICE:QUERY PLAN: <BR>
<P>
{AGG :cost 0 :size
0 :width 0 :state <> :qptargetlist <BR>
({TLE :resdom {RESDOM :resno 1 :restype
700 :restypmod 4 :resname "sum" <BR>
:reskey 0 :reskeyop 0 :resjunk 0}
<BR>
:expr {AGGREG :aggname "sum" :basetype 700 :aggtype 700 :aggno 0 <BR>
:target {VAR :varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno
1}}}) <BR>
:qpqual <> :lefttree {SEQSCAN :cost 0 :size 0 :width 4 :state <> <BR>
:qptargetlist ({TLE :resdom {RESDOM :resno 1 :restype 700 :restypmod
4 <BR>
:resname "null" :reskey 0 :reskeyop 0 :resjunk 0} <BR>
:expr {VAR
:varno 1 :varattno 1 :vartype 700 :varnoold 1 :varoattno 1}}) <BR>
:qpqual
<> :lefttree <> :righttree <> :scanrelid 1} :righttree <> :numagg 1 } <BR>
<P>
Aggregate
(cost=0.00 size=0 width=0) <BR>
-> Seq Scan on test (cost=0.00 size=0 width=4)
<BR>
<P>
The Postgres optimizer has chosen to use a sequential scan to retrieve
rows from this table. Indices will used by the optimizer after tables grow
large enough to warrant the access overhead; typically this might happen
when tables have a few hundred rows. <P>
<H2><A NAME="sect4" HREF="#toc4">SEE ALSO </A></H2>
<A HREF="delete.l.html">delete(l)</A>
, <A HREF="insert.l.html">insert(l)</A>
, <A HREF="select.l.html">select(l)</A>
.
<P>
<H2><A NAME="sect5" HREF="#toc5">BUGS </A></H2>
<P>
<P>
The query cost and plan can be affected by running vacuum. <P>
<P>
<HR><P>
<A NAME="toc"><B>Table of Contents</B></A><P>
<UL>
<LI><A NAME="toc0" HREF="#sect0">NAME</A></LI>
<LI><A NAME="toc1" HREF="#sect1">SYNOPSIS</A></LI>
<LI><A NAME="toc2" HREF="#sect2">DESCRIPTION</A></LI>
<LI><A NAME="toc3" HREF="#sect3">EXAMPLES</A></LI>
<LI><A NAME="toc4" HREF="#sect4">SEE ALSO</A></LI>
<LI><A NAME="toc5" HREF="#sect5">BUGS</A></LI>
</UL>
</BODY></HTML>
|