git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: de239d0)
Add WAL usage reporting to ANALYZE VERBOSE output.
Mon, 9 Sep 2024 21:56:08 +0000 (14:56 -0700)
Mon, 9 Sep 2024 21:56:08 +0000 (14:56 -0700)
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


diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 902eb1a450863eb5bd8b77f2a49e1b2b6a36d681..38fb4c3ef2328733f2b14152504e17e266f4a5db 100644 (file)
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -305,6 +305,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
Oid save_userid;
int save_sec_context;
int save_nestlevel;
+ WalUsage startwalusage = pgWalUsage;
BufferUsage startbufferusage = pgBufferUsage;
BufferUsage bufferusage;
PgStat_Counter startreadtime = 0;
@@ -740,6 +741,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
params->log_min_duration))
{
long delay_in_ms;
+ WalUsage walusage;
double read_rate = 0;
double write_rate = 0;
char *msgfmt;
@@ -750,6 +752,8 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
memset(&bufferusage, 0, sizeof(BufferUsage));
BufferUsageAccumDiff(&bufferusage, &pgBufferUsage, &startbufferusage);
+ memset(&walusage, 0, sizeof(WalUsage));
+ WalUsageAccumDiff(&walusage, &pgWalUsage, &startwalusage);
total_blks_hit = bufferusage.shared_blks_hit +
bufferusage.local_blks_hit;
@@ -818,6 +822,11 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
(long long) total_blks_hit,
(long long) total_blks_read,
(long long) total_blks_dirtied);
+ appendStringInfo(&buf,
+ _("WAL usage: %lld records, %lld full page images, %llu bytes\n"),
+ (long long) walusage.wal_records,
+ (long long) walusage.wal_fpi,
+ (unsigned long long) walusage.wal_bytes);
appendStringInfo(&buf, _("system usage: %s"), pg_rusage_show(&ru0));
ereport(verbose ? INFO : LOG,
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /