diff options
| author | Tom Lane | 2024-04-03 21:41:54 +0000 |
|---|---|---|
| committer | Tom Lane | 2024-04-03 21:41:57 +0000 |
| commit | 06286709ee0637ec7376329a5aa026b7682dcfe2 (patch) | |
| tree | f1c4f4b606b28227c401be2722b1d08c924586e9 /src/test | |
| parent | 97ce821e3e171ce99fa7c398889ac08432cd0264 (diff) | |
Invent SERIALIZE option for EXPLAIN.
EXPLAIN (ANALYZE, SERIALIZE) allows collection of statistics about
the volume of data emitted by a query, as well as the time taken
to convert the data to the on-the-wire format. Previously there
was no way to investigate this without actually sending the data
to the client, in which case network transmission costs might
swamp what you wanted to see. In particular this feature allows
investigating the costs of de-TOASTing compressed or out-of-line
data during formatting.
Stepan Rutz and Matthias van de Meent,
reviewed by Tomas Vondra and myself
Discussion: https://postgr.es/m/ca0adb0e-fa4e-c37e-1cd7-91170b18cae1@gmx.de
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/explain.out | 54 | ||||
| -rw-r--r-- | src/test/regress/sql/explain.sql | 9 |
2 files changed, 61 insertions, 2 deletions
diff --git a/src/test/regress/expected/explain.out b/src/test/regress/expected/explain.out index 1299ee79ad5..703800d856d 100644 --- a/src/test/regress/expected/explain.out +++ b/src/test/regress/expected/explain.out @@ -135,7 +135,7 @@ select explain_filter('explain (analyze, buffers, format xml) select * from int8 </explain> (1 row) -select explain_filter('explain (analyze, buffers, format yaml) select * from int8_tbl i8'); +select explain_filter('explain (analyze, serialize, buffers, format yaml) select * from int8_tbl i8'); explain_filter ------------------------------- - Plan: + @@ -175,6 +175,20 @@ select explain_filter('explain (analyze, buffers, format yaml) select * from int Temp Written Blocks: N + Planning Time: N.N + Triggers: + + Serialization: + + Time: N.N + + Output Volume: N + + Format: "text" + + Shared Hit Blocks: N + + Shared Read Blocks: N + + Shared Dirtied Blocks: N + + Shared Written Blocks: N + + Local Hit Blocks: N + + Local Read Blocks: N + + Local Dirtied Blocks: N + + Local Written Blocks: N + + Temp Read Blocks: N + + Temp Written Blocks: N + Execution Time: N.N (1 row) @@ -639,3 +653,41 @@ select explain_filter('explain (verbose) select * from int8_tbl i8'); Query Identifier: N (3 rows) +-- Test SERIALIZE option +select explain_filter('explain (analyze,serialize) select * from int8_tbl i8'); + explain_filter +----------------------------------------------------------------------------------------------- + Seq Scan on int8_tbl i8 (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N loops=N) + Planning Time: N.N ms + Serialization: time=N.N ms output=NkB format=text + Execution Time: N.N ms +(4 rows) + +select explain_filter('explain (analyze,serialize text,buffers,timing off) select * from int8_tbl i8'); + explain_filter +--------------------------------------------------------------------------------- + Seq Scan on int8_tbl i8 (cost=N.N..N.N rows=N width=N) (actual rows=N loops=N) + Planning Time: N.N ms + Serialization: output=NkB format=text + Execution Time: N.N ms +(4 rows) + +select explain_filter('explain (analyze,serialize binary,buffers,timing) select * from int8_tbl i8'); + explain_filter +----------------------------------------------------------------------------------------------- + Seq Scan on int8_tbl i8 (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N loops=N) + Planning Time: N.N ms + Serialization: time=N.N ms output=NkB format=binary + Execution Time: N.N ms +(4 rows) + +-- this tests an edge case where we have no data to return +select explain_filter('explain (analyze,serialize) create temp table explain_temp as select * from int8_tbl i8'); + explain_filter +----------------------------------------------------------------------------------------------- + Seq Scan on int8_tbl i8 (cost=N.N..N.N rows=N width=N) (actual time=N.N..N.N rows=N loops=N) + Planning Time: N.N ms + Serialization: time=N.N ms output=NkB format=text + Execution Time: N.N ms +(4 rows) + diff --git a/src/test/regress/sql/explain.sql b/src/test/regress/sql/explain.sql index 2274dc1b5a6..c7055f850c5 100644 --- a/src/test/regress/sql/explain.sql +++ b/src/test/regress/sql/explain.sql @@ -66,7 +66,7 @@ select explain_filter('explain (analyze) select * from int8_tbl i8'); select explain_filter('explain (analyze, verbose) select * from int8_tbl i8'); select explain_filter('explain (analyze, buffers, format text) select * from int8_tbl i8'); select explain_filter('explain (analyze, buffers, format xml) select * from int8_tbl i8'); -select explain_filter('explain (analyze, buffers, format yaml) select * from int8_tbl i8'); +select explain_filter('explain (analyze, serialize, buffers, format yaml) select * from int8_tbl i8'); select explain_filter('explain (buffers, format text) select * from int8_tbl i8'); select explain_filter('explain (buffers, format json) select * from int8_tbl i8'); @@ -162,3 +162,10 @@ select explain_filter('explain (verbose) select * from t1 where pg_temp.mysin(f1 -- Test compute_query_id set compute_query_id = on; select explain_filter('explain (verbose) select * from int8_tbl i8'); + +-- Test SERIALIZE option +select explain_filter('explain (analyze,serialize) select * from int8_tbl i8'); +select explain_filter('explain (analyze,serialize text,buffers,timing off) select * from int8_tbl i8'); +select explain_filter('explain (analyze,serialize binary,buffers,timing) select * from int8_tbl i8'); +-- this tests an edge case where we have no data to return +select explain_filter('explain (analyze,serialize) create temp table explain_temp as select * from int8_tbl i8'); |
