From: Amit Kapila Date: Tue, 5 May 2020 02:30:53 +0000 (+0530) Subject: Change the display of WAL usage statistics in Explain. X-Git-Url: http://git.postgresql.org/gitweb/-?a=commitdiff_plain;h=69bfaf2e1de49de76d7dec1c45511932a5ef502b;p=users%2Frhaas%2Fpostgres.git Change the display of WAL usage statistics in Explain. In commit 33e05f89c5, we have added the option to display WAL usage statistics in Explain and auto_explain. The display format used two spaces between each field which is inconsistent with Buffer usage statistics which is using one space between each field. Change the format to make WAL usage statistics consistent with Buffer usage statistics. This commit also changed the usage of "full page writes" to "full page images" for WAL usage statistics to make it consistent with other parts of code and docs. Author: Julien Rouhaud, Amit Kapila Reviewed-by: Justin Pryzby, Kyotaro Horiguchi and Amit Kapila Discussion: https://postgr.es/m/CAB-hujrP8ZfUkvL5OYETipQwA=e3n7oqHFU=4ZLxWS_Cza3kQQ@mail.gmail.com --- diff --git a/contrib/pg_stat_statements/pg_stat_statements--1.7--1.8.sql b/contrib/pg_stat_statements/pg_stat_statements--1.7--1.8.sql index d0a6c3b4fc..0f63f08f7e 100644 --- a/contrib/pg_stat_statements/pg_stat_statements--1.7--1.8.sql +++ b/contrib/pg_stat_statements/pg_stat_statements--1.7--1.8.sql @@ -43,7 +43,7 @@ CREATE FUNCTION pg_stat_statements(IN showtext boolean, OUT blk_read_time float8, OUT blk_write_time float8, OUT wal_records int8, - OUT wal_fpw int8, + OUT wal_fpi int8, OUT wal_bytes numeric ) RETURNS SETOF record diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c index 90bc6fd013..4ce25fb88a 100644 --- a/contrib/pg_stat_statements/pg_stat_statements.c +++ b/contrib/pg_stat_statements/pg_stat_statements.c @@ -189,7 +189,7 @@ typedef struct Counters double blk_write_time; /* time spent writing, in msec */ double usage; /* usage factor */ int64 wal_records; /* # of WAL records generated */ - int64 wal_fpw; /* # of WAL full page writes generated */ + int64 wal_fpi; /* # of WAL full page images generated */ uint64 wal_bytes; /* total amount of WAL bytes generated */ } Counters; @@ -1432,7 +1432,7 @@ pgss_store(const char *query, uint64 queryId, e->counters.blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_write_time); e->counters.usage += USAGE_EXEC(total_time); e->counters.wal_records += walusage->wal_records; - e->counters.wal_fpw += walusage->wal_fpw; + e->counters.wal_fpi += walusage->wal_fpi; e->counters.wal_bytes += walusage->wal_bytes; SpinLockRelease(&e->mutex); @@ -1824,7 +1824,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo, Datum wal_bytes; values[i++] = Int64GetDatumFast(tmp.wal_records); - values[i++] = Int64GetDatumFast(tmp.wal_fpw); + values[i++] = Int64GetDatumFast(tmp.wal_fpi); snprintf(buf, sizeof buf, UINT64_FORMAT, tmp.wal_bytes); diff --git a/doc/src/sgml/pgstatstatements.sgml b/doc/src/sgml/pgstatstatements.sgml index 2120fb4c3f..b1d5f3d1dc 100644 --- a/doc/src/sgml/pgstatstatements.sgml +++ b/doc/src/sgml/pgstatstatements.sgml @@ -283,11 +283,11 @@ - wal_fpw + wal_fpi bigint - Total number of WAL full page writes generated by the statement + Total number of WAL full page images generated by the statement diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index aedd70a6ad..c6f333c3c9 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -198,8 +198,8 @@ ROLLBACK; Include information on WAL record generation. Specifically, include the - number of records, number of full page writes and amount of WAL bytes - generated. In text format, only non-zero values are printed. This + number of records, number of full page images (fpi) and amount of WAL + bytes generated. In text format, only non-zero values are printed. This parameter may only be used when ANALYZE is also enabled. It defaults to FALSE. diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 3c18db29f1..3bef0e124b 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -673,10 +673,10 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params, read_rate, write_rate); appendStringInfo(&buf, _("system usage: %s\n"), pg_rusage_show(&ru0)); appendStringInfo(&buf, - _("WAL usage: %ld records, %ld full page writes, " + _("WAL usage: %ld records, %ld full page images, " UINT64_FORMAT " bytes"), walusage.wal_records, - walusage.wal_fpw, + walusage.wal_fpi, walusage.wal_bytes); ereport(LOG, diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 065eb275b1..0d3d670928 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -998,7 +998,7 @@ XLogRecPtr XLogInsertRecord(XLogRecData *rdata, XLogRecPtr fpw_lsn, uint8 flags, - int num_fpw) + int num_fpi) { XLogCtlInsert *Insert = &XLogCtl->Insert; pg_crc32c rdata_crc; @@ -1259,7 +1259,7 @@ XLogInsertRecord(XLogRecData *rdata, { pgWalUsage.wal_bytes += rechdr->xl_tot_len; pgWalUsage.wal_records++; - pgWalUsage.wal_fpw += num_fpw; + pgWalUsage.wal_fpi += num_fpi; } return EndPos; diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 4259309dba..b21679f09e 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -109,7 +109,7 @@ static MemoryContext xloginsert_cxt; static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info, XLogRecPtr RedoRecPtr, bool doPageWrites, - XLogRecPtr *fpw_lsn, int *num_fpw); + XLogRecPtr *fpw_lsn, int *num_fpi); static bool XLogCompressBackupBlock(char *page, uint16 hole_offset, uint16 hole_length, char *dest, uint16 *dlen); @@ -449,7 +449,7 @@ XLogInsert(RmgrId rmid, uint8 info) bool doPageWrites; XLogRecPtr fpw_lsn; XLogRecData *rdt; - int num_fpw = 0; + int num_fpi = 0; /* * Get values needed to decide whether to do full-page writes. Since @@ -459,9 +459,9 @@ XLogInsert(RmgrId rmid, uint8 info) GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites); rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites, - &fpw_lsn, &num_fpw); + &fpw_lsn, &num_fpi); - EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpw); + EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi); } while (EndPos == InvalidXLogRecPtr); XLogResetInsertion(); @@ -484,7 +484,7 @@ XLogInsert(RmgrId rmid, uint8 info) static XLogRecData * XLogRecordAssemble(RmgrId rmid, uint8 info, XLogRecPtr RedoRecPtr, bool doPageWrites, - XLogRecPtr *fpw_lsn, int *num_fpw) + XLogRecPtr *fpw_lsn, int *num_fpi) { XLogRecData *rdt; uint32 total_len = 0; @@ -638,7 +638,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, bkpb.fork_flags |= BKPBLOCK_HAS_IMAGE; /* Report a full page image constructed for the WAL record */ - *num_fpw += 1; + *num_fpi += 1; /* * Construct XLogRecData entries for the page content. diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 7ae6131676..1275bec673 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -3343,31 +3343,31 @@ show_wal_usage(ExplainState *es, const WalUsage *usage) if (es->format == EXPLAIN_FORMAT_TEXT) { /* Show only positive counter values. */ - if ((usage->wal_records > 0) || (usage->wal_fpw > 0) || + if ((usage->wal_records > 0) || (usage->wal_fpi > 0) || (usage->wal_bytes > 0)) { ExplainIndentText(es); appendStringInfoString(es->str, "WAL:"); if (usage->wal_records > 0) - appendStringInfo(es->str, " records=%ld", + appendStringInfo(es->str, " records=%ld", usage->wal_records); - if (usage->wal_fpw > 0) - appendStringInfo(es->str, " full page writes=%ld", - usage->wal_fpw); + if (usage->wal_fpi > 0) + appendStringInfo(es->str, " fpi=%ld", + usage->wal_fpi); if (usage->wal_bytes > 0) - appendStringInfo(es->str, " bytes=" UINT64_FORMAT, + appendStringInfo(es->str, " bytes=" UINT64_FORMAT, usage->wal_bytes); appendStringInfoChar(es->str, '\n'); } } else { - ExplainPropertyInteger("WAL records", NULL, + ExplainPropertyInteger("WAL Records", NULL, usage->wal_records, es); - ExplainPropertyInteger("WAL full page writes", NULL, - usage->wal_fpw, es); - ExplainPropertyUInteger("WAL bytes", NULL, + ExplainPropertyInteger("WAL FPI", NULL, + usage->wal_fpi, es); + ExplainPropertyUInteger("WAL Bytes", NULL, usage->wal_bytes, es); } } diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c index 7c9d723552..fbedb5aaf6 100644 --- a/src/backend/executor/instrument.c +++ b/src/backend/executor/instrument.c @@ -248,7 +248,7 @@ WalUsageAdd(WalUsage *dst, WalUsage *add) { dst->wal_bytes += add->wal_bytes; dst->wal_records += add->wal_records; - dst->wal_fpw += add->wal_fpw; + dst->wal_fpi += add->wal_fpi; } void @@ -256,5 +256,5 @@ WalUsageAccumDiff(WalUsage *dst, const WalUsage *add, const WalUsage *sub) { dst->wal_bytes += add->wal_bytes - sub->wal_bytes; dst->wal_records += add->wal_records - sub->wal_records; - dst->wal_fpw += add->wal_fpw - sub->wal_fpw; + dst->wal_fpi += add->wal_fpi - sub->wal_fpi; } diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 0a12afb59e..e917dfe92d 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -280,7 +280,7 @@ struct XLogRecData; extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata, XLogRecPtr fpw_lsn, uint8 flags, - int num_fpw); + int num_fpi); extern void XLogFlush(XLogRecPtr RecPtr); extern bool XLogBackgroundFlush(void); extern bool XLogNeedsFlush(XLogRecPtr RecPtr); diff --git a/src/include/executor/instrument.h b/src/include/executor/instrument.h index 50d672b270..a97562e7a4 100644 --- a/src/include/executor/instrument.h +++ b/src/include/executor/instrument.h @@ -35,7 +35,7 @@ typedef struct BufferUsage typedef struct WalUsage { long wal_records; /* # of WAL records produced */ - long wal_fpw; /* # of WAL full page writes produced */ + long wal_fpi; /* # of WAL full page images produced */ uint64 wal_bytes; /* size of WAL records produced */ } WalUsage;