1
1
<!--
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 $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -247,6 +247,29 @@ EXPLAIN SELECT * FROM foo;
247
247
</programlisting>
248
248
</para>
249
249
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
+
250
273
<para>
251
274
If there is an index and we use a query with an indexable
252
275
<literal>WHERE</literal> condition, <command>EXPLAIN</command>
@@ -263,6 +286,28 @@ EXPLAIN SELECT * FROM foo WHERE i = 4;
263
286
</programlisting>
264
287
</para>
265
288
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>
266
311
<para>
267
312
Here is the same plan with costs suppressed:
268
313
0 commit comments