Skip to content

Commit 83527b1

Browse files
committed
Add EXPLAIN documentation example.
gabrielle <gorthx@gmail.com>
1 parent 72405b0 commit 83527b1

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

doc/src/sgml/ref/explain.sgml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/explain.sgml,v 1.50 2010/04/03 07:23:01 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/explain.sgml,v 1.51 2010/08/03 17:14:19 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -247,6 +247,29 @@ EXPLAIN SELECT * FROM foo;
247247
</programlisting>
248248
</para>
249249

250+
<para>
251+
Here is the same query, with JSON formatting:
252+
<programlisting>
253+
EXPLAIN (FORMAT JSON) SELECT * FROM foo;
254+
QUERY PLAN
255+
--------------------------------
256+
[ +
257+
{ +
258+
"Plan": { +
259+
"Node Type": "Seq Scan",+
260+
"Relation Name": "foo", +
261+
"Alias": "foo", +
262+
"Startup Cost": 0.00, +
263+
"Total Cost": 155.00, +
264+
"Plan Rows": 10000, +
265+
"Plan Width": 4 +
266+
} +
267+
} +
268+
]
269+
(1 row)
270+
</programlisting>
271+
</para>
272+
250273
<para>
251274
If there is an index and we use a query with an indexable
252275
<literal>WHERE</literal> condition, <command>EXPLAIN</command>
@@ -263,6 +286,28 @@ EXPLAIN SELECT * FROM foo WHERE i = 4;
263286
</programlisting>
264287
</para>
265288

289+
<para>
290+
Here is the same query, but in YAML output:
291+
<programlisting>
292+
EXPLAIN (FORMAT YAML) SELECT * FROM foo WHERE i='4';
293+
QUERY PLAN
294+
-------------------------------
295+
- Plan: +
296+
Node Type: "Index Scan" +
297+
Scan Direction: "Forward"+
298+
Index Name: "fi" +
299+
Relation Name: "foo" +
300+
Alias: "foo" +
301+
Startup Cost: 0.00 +
302+
Total Cost: 5.98 +
303+
Plan Rows: 1 +
304+
Plan Width: 4 +
305+
Index Cond: "(i = 4)"
306+
(1 row)
307+
</programlisting>
308+
309+
XML output is left as an exercise to the reader.
310+
</para>
266311
<para>
267312
Here is the same plan with costs suppressed:
268313

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy