From 06286709ee0637ec7376329a5aa026b7682dcfe2 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 3 Apr 2024 17:41:54 -0400 Subject: 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 --- src/include/commands/explain.h | 10 ++++++++++ src/include/tcop/dest.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src/include') diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h index cf195f13597..9b8b351d9a2 100644 --- a/src/include/commands/explain.h +++ b/src/include/commands/explain.h @@ -17,6 +17,13 @@ #include "lib/stringinfo.h" #include "parser/parse_node.h" +typedef enum ExplainSerializeOption +{ + EXPLAIN_SERIALIZE_NONE, + EXPLAIN_SERIALIZE_TEXT, + EXPLAIN_SERIALIZE_BINARY, +} ExplainSerializeOption; + typedef enum ExplainFormat { EXPLAIN_FORMAT_TEXT, @@ -48,6 +55,7 @@ typedef struct ExplainState bool memory; /* print planner's memory usage information */ bool settings; /* print modified settings */ bool generic; /* generate a generic plan */ + ExplainSerializeOption serialize; /* serialize the query's output? */ ExplainFormat format; /* output format */ /* state for output formatting --- not reset for each new plan tree */ int indent; /* current indentation level */ @@ -132,4 +140,6 @@ extern void ExplainOpenGroup(const char *objtype, const char *labelname, extern void ExplainCloseGroup(const char *objtype, const char *labelname, bool labeled, ExplainState *es); +extern DestReceiver *CreateExplainSerializeDestReceiver(ExplainState *es); + #endif /* EXPLAIN_H */ diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h index 7e613bd7fcc..a3d521b6f97 100644 --- a/src/include/tcop/dest.h +++ b/src/include/tcop/dest.h @@ -96,6 +96,7 @@ typedef enum DestSQLFunction, /* results sent to SQL-language func mgr */ DestTransientRel, /* results sent to transient relation */ DestTupleQueue, /* results sent to tuple queue */ + DestExplainSerialize, /* results are serialized and discarded */ } CommandDest; /* ---------------- -- cgit v1.2.3