diff options
| author | Bruce Momjian <bruce@momjian.us> | 2010-08-09 23:49:33 +0000 | 
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2010-08-09 23:49:33 +0000 | 
| commit | 4798e2144770969ea3436933bbfe6e0367b3bdca (patch) | |
| tree | f99ed1c19dd2ebf75f373bea7514aa54f799c15c | |
| parent | 6d301d938f7d7cb19f730eff44e65bc8addde68a (diff) | |
Add EXPLAIN documentation example.
gabrielle <gorthx@gmail.com>
Backpatch to 9.0.X.
| -rw-r--r-- | doc/src/sgml/ref/explain.sgml | 47 | 
1 files changed, 46 insertions, 1 deletions
diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index cf4aa8f7622..f31969b81b1 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -1,5 +1,5 @@  <!-- -$PostgreSQL: pgsql/doc/src/sgml/ref/explain.sgml,v 1.50 2010/04/03 07:23:01 petere Exp $ +$PostgreSQL: pgsql/doc/src/sgml/ref/explain.sgml,v 1.50.2.1 2010/08/09 23:49:33 momjian Exp $  PostgreSQL documentation  --> @@ -248,6 +248,29 @@ EXPLAIN SELECT * FROM foo;    </para>    <para> +  Here is the same query, with JSON formatting: +<programlisting> +EXPLAIN (FORMAT JSON) SELECT * FROM foo; +           QUERY PLAN            +-------------------------------- + [                             + +   {                           + +     "Plan": {                 + +       "Node Type": "Seq Scan",+ +       "Relation Name": "foo", + +       "Alias": "foo",         + +       "Startup Cost": 0.00,   + +       "Total Cost": 155.00,   + +       "Plan Rows": 10000,     + +       "Plan Width": 4         + +     }                         + +   }                           + + ] +(1 row) +</programlisting> +  </para> + +  <para>     If there is an index and we use a query with an indexable     <literal>WHERE</literal> condition, <command>EXPLAIN</command>     might show a different plan: @@ -264,6 +287,28 @@ EXPLAIN SELECT * FROM foo WHERE i = 4;    </para>    <para> +  Here is the same query, but in YAML output: +<programlisting> +EXPLAIN (FORMAT YAML) SELECT * FROM foo WHERE i='4'; +          QUERY PLAN            +------------------------------- + - Plan:                      + +     Node Type: "Index Scan"  + +     Scan Direction: "Forward"+ +     Index Name: "fi"         + +     Relation Name: "foo"     + +     Alias: "foo"             + +     Startup Cost: 0.00       + +     Total Cost: 5.98         + +     Plan Rows: 1             + +     Plan Width: 4            + +     Index Cond: "(i = 4)" +(1 row) +</programlisting> + +    XML output is left as an exercise to the reader. +  </para> +  <para>     Here is the same plan with costs suppressed:  <programlisting>  | 
