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

Commit4c1b4cd

Browse files
Add resource statistics reporting to ANALYZE VERBOSE.
Previously, log_autovacuum_min_duration utilized dedicated code forlogging resource statistics, such as system and buffer usage duringautoanalyze. However, this logging functionality was not utilized byANALYZE VERBOSE.This commit adds resource statistics reporting to ANALYZE VERBOSE byreusing the same logging code as autoanalyze.Author: Anthonin BonnefoyReviewed-by: Masahiko SawadaDiscussion:https://postgr.es/m/CAO6_Xqr__kTTCLkftqS0qSCm-J7_xbRG3Ge2rWhucxQJMJhcRA%40mail.gmail.com
1 parentc584781 commit4c1b4cd

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

‎src/backend/commands/analyze.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
288288
ind;
289289
Relation*Irel;
290290
intnindexes;
291-
boolhasindex;
291+
boolverbose,
292+
instrument,
293+
hasindex;
292294
VacAttrStats**vacattrstats;
293295
AnlIndexData*indexdata;
294296
inttargrows,
@@ -308,6 +310,9 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
308310
PgStat_Counterstartreadtime=0;
309311
PgStat_Counterstartwritetime=0;
310312

313+
verbose= (params->options&VACOPT_VERBOSE)!=0;
314+
instrument= (verbose|| (AmAutoVacuumWorkerProcess()&&
315+
params->log_min_duration >=0));
311316
if (inh)
312317
ereport(elevel,
313318
(errmsg("analyzing \"%s.%s\" inheritance tree",
@@ -339,8 +344,11 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
339344
save_nestlevel=NewGUCNestLevel();
340345
RestrictSearchPath();
341346

342-
/* measure elapsed time iff autovacuum logging requires it */
343-
if (AmAutoVacuumWorkerProcess()&&params->log_min_duration >=0)
347+
/*
348+
* measure elapsed time if called with verbose or if autovacuum logging
349+
* requires it
350+
*/
351+
if (instrument)
344352
{
345353
if (track_io_timing)
346354
{
@@ -723,17 +731,18 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
723731
vac_close_indexes(nindexes,Irel,NoLock);
724732

725733
/* Log the action if appropriate */
726-
if (AmAutoVacuumWorkerProcess()&&params->log_min_duration >=0)
734+
if (instrument)
727735
{
728736
TimestampTzendtime=GetCurrentTimestamp();
729737

730-
if (params->log_min_duration==0||
738+
if (verbose||params->log_min_duration==0||
731739
TimestampDifferenceExceeds(starttime,endtime,
732740
params->log_min_duration))
733741
{
734742
longdelay_in_ms;
735743
doubleread_rate=0;
736744
doublewrite_rate=0;
745+
char*msgfmt;
737746
StringInfoDatabuf;
738747
int64total_blks_hit;
739748
int64total_blks_read;
@@ -785,7 +794,13 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
785794
*/
786795

787796
initStringInfo(&buf);
788-
appendStringInfo(&buf,_("automatic analyze of table \"%s.%s.%s\"\n"),
797+
798+
if (AmAutoVacuumWorkerProcess())
799+
msgfmt=_("automatic analyze of table \"%s.%s.%s\"\n");
800+
else
801+
msgfmt=_("finished analyzing table \"%s.%s.%s\"\n");
802+
803+
appendStringInfo(&buf,msgfmt,
789804
get_database_name(MyDatabaseId),
790805
get_namespace_name(RelationGetNamespace(onerel)),
791806
RelationGetRelationName(onerel));
@@ -805,7 +820,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
805820
(long long)total_blks_dirtied);
806821
appendStringInfo(&buf,_("system usage: %s"),pg_rusage_show(&ru0));
807822

808-
ereport(LOG,
823+
ereport(verbose ?INFO :LOG,
809824
(errmsg_internal("%s",buf.data)));
810825

811826
pfree(buf.data);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp