Skip to content

Commit e2a0fc5

Browse files
committed
auto_explain: Add logging of trigger execution
Author: Kyotaro HORIGUCHI Reviewed-by: Jaime Casanova
1 parent 84df54b commit e2a0fc5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

contrib/auto_explain/auto_explain.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static int auto_explain_log_min_duration = -1; /* msec or -1 */
2525
static bool auto_explain_log_analyze = false;
2626
static bool auto_explain_log_verbose = false;
2727
static bool auto_explain_log_buffers = false;
28+
static bool auto_explain_log_triggers = false;
2829
static bool auto_explain_log_timing = false;
2930
static int auto_explain_log_format = EXPLAIN_FORMAT_TEXT;
3031
static bool auto_explain_log_nested_statements = false;
@@ -113,6 +114,17 @@ _PG_init(void)
113114
NULL,
114115
NULL);
115116

117+
DefineCustomBoolVariable("auto_explain.log_triggers",
118+
"Include trigger statistics in plans.",
119+
"This has no effect unless log_analyze is also set.",
120+
&auto_explain_log_triggers,
121+
false,
122+
PGC_SUSET,
123+
0,
124+
NULL,
125+
NULL,
126+
NULL);
127+
116128
DefineCustomEnumVariable("auto_explain.log_format",
117129
"EXPLAIN format to be used for plan logging.",
118130
NULL,
@@ -295,6 +307,8 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
295307
ExplainBeginOutput(&es);
296308
ExplainQueryText(&es, queryDesc);
297309
ExplainPrintPlan(&es, queryDesc);
310+
if (es.analyze && auto_explain_log_triggers)
311+
ExplainPrintTriggers(&es, queryDesc);
298312
ExplainEndOutput(&es);
299313

300314
/* Remove last line break */

doc/src/sgml/auto-explain.sgml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@ LOAD 'auto_explain';
122122
</listitem>
123123
</varlistentry>
124124

125+
<varlistentry>
126+
<term>
127+
<varname>auto_explain.log_triggers</varname> (<type>boolean</type>)
128+
</term>
129+
<indexterm>
130+
<primary><varname>auto_explain.log_triggers</> configuration parameter</primary>
131+
</indexterm>
132+
<listitem>
133+
<para>
134+
<varname>auto_explain.log_triggers</varname> causes trigger
135+
execution statistics to be included when an execution plan is logged.
136+
This parameter is off by default. Only superusers can change this
137+
setting. This parameter has no effect unless
138+
<varname>auto_explain.log_analyze</> parameter is set.
139+
</para>
140+
</listitem>
141+
</varlistentry>
142+
125143
<varlistentry>
126144
<term>
127145
<varname>auto_explain.log_format</varname> (<type>enum</type>)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy