Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit898f8a9

Browse files
committed
Fix failure of contrib/auto_explain to print per-node timing information.
This has been broken since commitaf7914c,which added the EXPLAIN (TIMING) option. Although that commit includedupdates to auto_explain, they evidently weren't tested very carefully,because the code failed to print node timings even when it should, due tofailure to set es.timing in the ExplainState struct. Reported off-list byNeelakanth Nadgir of Salesforce.In passing, clean up the documentation for auto_explain's options alittle bit, including re-ordering them into what seems to me a morelogical order.
1 parenta92b5f9 commit898f8a9

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

‎contrib/auto_explain/auto_explain.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static bool auto_explain_log_analyze = false;
2626
staticboolauto_explain_log_verbose= false;
2727
staticboolauto_explain_log_buffers= false;
2828
staticboolauto_explain_log_triggers= false;
29-
staticboolauto_explain_log_timing=false;
29+
staticboolauto_explain_log_timing=true;
3030
staticintauto_explain_log_format=EXPLAIN_FORMAT_TEXT;
3131
staticboolauto_explain_log_nested_statements= false;
3232

@@ -200,8 +200,6 @@ explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
200200
queryDesc->instrument_options |=INSTRUMENT_TIMER;
201201
else
202202
queryDesc->instrument_options |=INSTRUMENT_ROWS;
203-
204-
205203
if (auto_explain_log_buffers)
206204
queryDesc->instrument_options |=INSTRUMENT_BUFFERS;
207205
}
@@ -302,6 +300,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc)
302300
es.analyze= (queryDesc->instrument_options&&auto_explain_log_analyze);
303301
es.verbose=auto_explain_log_verbose;
304302
es.buffers= (es.analyze&&auto_explain_log_buffers);
303+
es.timing= (es.analyze&&auto_explain_log_timing);
305304
es.format=auto_explain_log_format;
306305

307306
ExplainBeginOutput(&es);

‎doc/src/sgml/auto-explain.sgml

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -81,43 +81,53 @@ LOAD 'auto_explain';
8181
When this parameter is on, per-plan-node timing occurs for all
8282
statements executed, whether or not they run long enough to actually
8383
get logged. This can have an extremely negative impact on performance.
84+
Turning off <varname>auto_explain.log_timing</varname> ameliorates the
85+
performance cost, at the price of obtaining less information.
8486
</para>
8587
</note>
8688
</listitem>
8789
</varlistentry>
8890

8991
<varlistentry>
9092
<term>
91-
<varname>auto_explain.log_verbose</varname> (<type>boolean</type>)
93+
<varname>auto_explain.log_buffers</varname> (<type>boolean</type>)
9294
<indexterm>
93-
<primary><varname>auto_explain.log_verbose</> configuration parameter</primary>
95+
<primary><varname>auto_explain.log_buffers</> configuration parameter</primary>
9496
</indexterm>
9597
</term>
9698
<listitem>
9799
<para>
98-
<varname>auto_explain.log_verbose</varname> causes <command>EXPLAIN VERBOSE</>
99-
output, rather than just <command>EXPLAIN</> output, to be printed
100-
when an execution plan is logged. This parameter is off by default.
100+
<varname>auto_explain.log_buffers</varname> controls whether buffer
101+
usage statistics are printed when an execution plan is logged; it's
102+
equivalent to the <literal>BUFFERS</> option of <command>EXPLAIN</>.
103+
This parameter has no effect
104+
unless <varname>auto_explain.log_analyze</varname> is enabled.
105+
This parameter is off by default.
101106
Only superusers can change this setting.
102107
</para>
103108
</listitem>
104109
</varlistentry>
105110

106111
<varlistentry>
107112
<term>
108-
<varname>auto_explain.log_buffers</varname> (<type>boolean</type>)
113+
<varname>auto_explain.log_timing</varname> (<type>boolean</type>)
109114
<indexterm>
110-
<primary><varname>auto_explain.log_buffers</> configuration parameter</primary>
115+
<primary><varname>auto_explain.log_timing</> configuration parameter</primary>
111116
</indexterm>
112117
</term>
113118
<listitem>
114119
<para>
115-
<varname>auto_explain.log_buffers</varname> causes <command>EXPLAIN
116-
(ANALYZE, BUFFERS)</> output, rather than just <command>EXPLAIN</>
117-
output, to be printed when an execution plan is logged. This parameter is
118-
off by default. Only superusers can change this setting. This
119-
parameter has no effect unless <varname>auto_explain.log_analyze</>
120-
parameter is set.
120+
<varname>auto_explain.log_timing</varname> controls whether per-node
121+
timing information is printed when an execution plan is logged; it's
122+
equivalent to the <literal>TIMING</> option of <command>EXPLAIN</>.
123+
The overhead of repeatedly reading the system clock can slow down
124+
queries significantly on some systems, so it may be useful to set this
125+
parameter to off when only actual row counts, and not exact times, are
126+
needed.
127+
This parameter has no effect
128+
unless <varname>auto_explain.log_analyze</varname> is enabled.
129+
This parameter is on by default.
130+
Only superusers can change this setting.
121131
</para>
122132
</listitem>
123133
</varlistentry>
@@ -133,52 +143,50 @@ LOAD 'auto_explain';
133143
<para>
134144
<varname>auto_explain.log_triggers</varname> causes trigger
135145
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.
146+
This parameter has no effect
147+
unless <varname>auto_explain.log_analyze</varname> is enabled.
148+
This parameter is off by default.
149+
Only superusers can change this setting.
139150
</para>
140151
</listitem>
141152
</varlistentry>
142153

143154
<varlistentry>
144155
<term>
145-
<varname>auto_explain.log_format</varname> (<type>enum</type>)
156+
<varname>auto_explain.log_verbose</varname> (<type>boolean</type>)
146157
<indexterm>
147-
<primary><varname>auto_explain.log_format</> configuration parameter</primary>
158+
<primary><varname>auto_explain.log_verbose</> configuration parameter</primary>
148159
</indexterm>
149160
</term>
150161
<listitem>
151162
<para>
152-
<varname>auto_explain.log_format</varname>selects the
153-
<command>EXPLAIN</> output format to be used.
154-
The allowed values are<literal>text</literal>, <literal>xml</literal>,
155-
<literal>json</literal>, and <literal>yaml</literal>. The default is text.
163+
<varname>auto_explain.log_verbose</varname>controls whether verbose
164+
details are printed when an execution plan is logged; it's
165+
equivalent to the<literal>VERBOSE</> option of <command>EXPLAIN</>.
166+
This parameter is off by default.
156167
Only superusers can change this setting.
157168
</para>
158169
</listitem>
159170
</varlistentry>
160171

161172
<varlistentry>
162173
<term>
163-
<varname>auto_explain.log_timing</varname> (<type>boolean</type>)
174+
<varname>auto_explain.log_format</varname> (<type>enum</type>)
164175
<indexterm>
165-
<primary><varname>auto_explain.log_timing</> configuration parameter</primary>
176+
<primary><varname>auto_explain.log_format</> configuration parameter</primary>
166177
</indexterm>
167178
</term>
168179
<listitem>
169180
<para>
170-
<varname>auto_explain.log_timing</varname> causes <command>EXPLAIN
171-
(ANALYZE, TIMING off)</> output, rather than just <command>EXPLAIN (ANALYZE)</>
172-
output. The overhead of repeatedly reading the system clock can slow down the
173-
query significantly on some systems, so it may be useful to set this
174-
parameter to off when only actual row counts, and not exact times, are needed.
175-
This parameter is only effective when <varname>auto_explain.log_analyze</varname>
176-
is also enabled. This parameter is on by default.
181+
<varname>auto_explain.log_format</varname> selects the
182+
<command>EXPLAIN</> output format to be used.
183+
The allowed values are <literal>text</literal>, <literal>xml</literal>,
184+
<literal>json</literal>, and <literal>yaml</literal>. The default is text.
177185
Only superusers can change this setting.
178186
</para>
179187
</listitem>
180188
</varlistentry>
181-
189+
182190
<varlistentry>
183191
<term>
184192
<varname>auto_explain.log_nested_statements</varname> (<type>boolean</type>)
@@ -198,7 +206,9 @@ LOAD 'auto_explain';
198206
</variablelist>
199207

200208
<para>
201-
These parameters must be set in <filename>postgresql.conf</>.
209+
In ordinary usage, these parameters are set
210+
in <filename>postgresql.conf</>, although superusers can alter them
211+
on-the-fly within their own sessions.
202212
Typical usage might be:
203213
</para>
204214

@@ -216,6 +226,7 @@ auto_explain.log_min_duration = '3s'
216226
<programlisting>
217227
postgres=# LOAD 'auto_explain';
218228
postgres=# SET auto_explain.log_min_duration = 0;
229+
postgres=# SET auto_explain.log_analyze = true;
219230
postgres=# SELECT count(*)
220231
FROM pg_class, pg_index
221232
WHERE oid = indrelid AND indisunique;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp