Hi,
As far as I read the manual below, auto_explain.log_verbose should
record logs equivalent to VERBOSE option of EXPLAIN.
-- https://www.postgresql.org/docs/devel/auto-explain.html
auto_explain.log_verbose controls whether verbose details are printed
when an execution plan is logged; it's equivalent to the VERBOSE option
of EXPLAIN.
However, when compute_query_id is on, query identifiers are only printed
when using VERBOSE option of EXPLAIN.
EXPLAIN VERBOSE:
```
=# show auto_explain.log_verbose;
auto_explain.log_verbose
--------------------------
on
(1 row)
=# show compute_query_id;
compute_query_id
------------------
on
(1 row)
=# explain verbose select 1;
QUERY PLAN
------------------------------------------
Result (cost=0.00..0.01 rows=1 width=4)
Output: 1
Query Identifier: -1801652217649936326
(3 rows)
```
auto_explain:
```
LOG: 00000: duration: 0.000 ms plan:
Query Text: explain verbose select 1;
Result (cost=0.00..0.01 rows=1 width=4)
Output: 1
```
Attached patch makes auto_explain also print query identifiers.
What do you think?
--
Regards,
--
Atsushi Torikoshi
NTT DATA CORPORATION
From 0e2612a1c7762b64357c85ce04e62b5ba0cdb4f7 Mon Sep 17 00:00:00 2001
From: Atsushi Torikoshi <torikos...@oss.nttdata.com>
Date: Mon, 16 Jan 2023 20:41:09 +0900
Subject: [PATCH v1] Make auto_explain record query identifier
When auto_explain.log_verbose is on, auto_explain should record logs
equivalent to VERBOSE option of EXPLAIN. Howerver, when
compute_query_id is on, query identifiers are only printed in
VERBOSE option of EXPLAIN.
This patch makes auto_explain also print query identifier.
---
contrib/auto_explain/auto_explain.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c
index c3ac27ae99..79d4ad6785 100644
--- a/contrib/auto_explain/auto_explain.c
+++ b/contrib/auto_explain/auto_explain.c
@@ -21,6 +21,7 @@
#include "jit/jit.h"
#include "nodes/params.h"
#include "utils/guc.h"
+#include "utils/queryjumble.h"
PG_MODULE_MAGIC;
@@ -407,6 +408,9 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
ExplainPrintTriggers(es, queryDesc);
if (es->costs)
ExplainPrintJITSummary(es, queryDesc);
+ if (es->verbose && queryDesc->plannedstmt->queryId != UINT64CONST(0))
+ ExplainPropertyInteger("Query Identifier", NULL, (int64)
+ queryDesc->plannedstmt->queryId, es);
ExplainEndOutput(es);
/* Remove last line break */
base-commit: 1561612e3bf3264c31618b9455d0c1003b9271ec
--
2.25.1