Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bb77752

Browse files
Add WAL usage reporting to ANALYZE VERBOSE output.
This change adds WAL usage reporting to the output of ANALYZE VERBOSE and autoanalyze reports. It aligns the analyze output with VACUUM, providing consistency. Additionally, it aids in troubleshooting cases where WAL records are generated during analyze operations. Author: Anthonin Bonnefoy Reviewed-by: Masahiko Sawada Discussion: https://postgr.es/m/CAO6_Xqr__kTTCLkftqS0qSCm-J7_xbRG3Ge2rWhucxQJMJhcRA%40mail.gmail.com
1 parent de239d0 commit bb77752

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/backend/commands/analyze.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
305305
Oid save_userid;
306306
int save_sec_context;
307307
int save_nestlevel;
308+
WalUsage startwalusage = pgWalUsage;
308309
BufferUsage startbufferusage = pgBufferUsage;
309310
BufferUsage bufferusage;
310311
PgStat_Counter startreadtime = 0;
@@ -740,6 +741,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
740741
params->log_min_duration))
741742
{
742743
long delay_in_ms;
744+
WalUsage walusage;
743745
double read_rate = 0;
744746
double write_rate = 0;
745747
char *msgfmt;
@@ -750,6 +752,8 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
750752

751753
memset(&bufferusage, 0, sizeof(BufferUsage));
752754
BufferUsageAccumDiff(&bufferusage, &pgBufferUsage, &startbufferusage);
755+
memset(&walusage, 0, sizeof(WalUsage));
756+
WalUsageAccumDiff(&walusage, &pgWalUsage, &startwalusage);
753757

754758
total_blks_hit = bufferusage.shared_blks_hit +
755759
bufferusage.local_blks_hit;
@@ -818,6 +822,11 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
818822
(long long) total_blks_hit,
819823
(long long) total_blks_read,
820824
(long long) total_blks_dirtied);
825+
appendStringInfo(&buf,
826+
_("WAL usage: %lld records, %lld full page images, %llu bytes\n"),
827+
(long long) walusage.wal_records,
828+
(long long) walusage.wal_fpi,
829+
(unsigned long long) walusage.wal_bytes);
821830
appendStringInfo(&buf, _("system usage: %s"), pg_rusage_show(&ru0));
822831

823832
ereport(verbose ? INFO : LOG,

0 commit comments

Comments
 (0)