1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +03:00

Include planning time in EXPLAIN ANALYZE output.

This doesn't work for prepared queries, but it's not too easy to get
the information in that case and there's some debate as to exactly
what the right thing to measure is, so just do this for now.

Andreas Karlsson, with slight doc changes by me.
This commit is contained in:
Robert Haas
2014-01-29 16:04:19 -05:00
parent 5264d91541
commit 9347baa5bb
5 changed files with 63 additions and 11 deletions

View File

@@ -145,7 +145,8 @@ ROLLBACK;
<para>
Include information on the estimated startup and total cost of each
plan node, as well as the estimated number of rows and the estimated
width of each row. This parameter defaults to <literal>TRUE</literal>.
width of each row. Also, include the time spent planning the query,
if available. This parameter defaults to <literal>TRUE</literal>.
</para>
</listitem>
</varlistentry>
@@ -289,7 +290,8 @@ EXPLAIN SELECT * FROM foo;
QUERY PLAN
---------------------------------------------------------
Seq Scan on foo (cost=0.00..155.00 rows=10000 width=4)
(1 row)
Planning time: 0.114 ms
(2 rows)
</programlisting>
</para>
@@ -309,7 +311,8 @@ EXPLAIN (FORMAT JSON) SELECT * FROM foo;
"Total Cost": 155.00, +
"Plan Rows": 10000, +
"Plan Width": 4 +
} +
}. +
"Planning Time": 0.114 +
} +
]
(1 row)
@@ -328,7 +331,8 @@ EXPLAIN SELECT * FROM foo WHERE i = 4;
--------------------------------------------------------------
Index Scan using fi on foo (cost=0.00..5.98 rows=1 width=4)
Index Cond: (i = 4)
(2 rows)
Planning time: 0.073 ms
(3 rows)
</programlisting>
</para>
@@ -348,7 +352,8 @@ EXPLAIN (FORMAT YAML) SELECT * FROM foo WHERE i='4';
Total Cost: 5.98 +
Plan Rows: 1 +
Plan Width: 4 +
Index Cond: "(i = 4)"
Index Cond: "(i = 4)" +
Planning Time: 0.073
(1 row)
</programlisting>
@@ -380,6 +385,7 @@ EXPLAIN SELECT sum(i) FROM foo WHERE i &lt; 10;
Aggregate (cost=23.93..23.93 rows=1 width=4)
-&gt; Index Scan using fi on foo (cost=0.00..23.92 rows=6 width=4)
Index Cond: (i &lt; 10)
Planning time: 0.088 ms
(3 rows)
</programlisting>
</para>
@@ -401,6 +407,7 @@ EXPLAIN ANALYZE EXECUTE query(100, 200);
Group Key: foo
-&gt; Index Scan using test_pkey on test (cost=0.29..9.29 rows=50 width=8) (actual time=0.039..0.091 rows=99 loops=1)
Index Cond: ((id &gt; $1) AND (id &lt; $2))
Planning time: 0.197 ms
Total runtime: 0.225 ms
(5 rows)
</programlisting>