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

Commit 69bfaf2

Browse files
author
Amit Kapila
committed
Change the display of WAL usage statistics in Explain.
In commit 33e05f8, 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
1 parent 5545b69 commit 69bfaf2

File tree

11 files changed

+32
-32
lines changed

11 files changed

+32
-32
lines changed

contrib/pg_stat_statements/pg_stat_statements--1.7--1.8.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CREATE FUNCTION pg_stat_statements(IN showtext boolean,
4343
OUT blk_read_time float8,
4444
OUT blk_write_time float8,
4545
OUT wal_records int8,
46-
OUT wal_fpw int8,
46+
OUT wal_fpi int8,
4747
OUT wal_bytes numeric
4848
)
4949
RETURNS SETOF record

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ typedef struct Counters
189189
double blk_write_time; /* time spent writing, in msec */
190190
double usage; /* usage factor */
191191
int64 wal_records; /* # of WAL records generated */
192-
int64 wal_fpw; /* # of WAL full page writes generated */
192+
int64 wal_fpi; /* # of WAL full page images generated */
193193
uint64 wal_bytes; /* total amount of WAL bytes generated */
194194
} Counters;
195195

@@ -1432,7 +1432,7 @@ pgss_store(const char *query, uint64 queryId,
14321432
e->counters.blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_write_time);
14331433
e->counters.usage += USAGE_EXEC(total_time);
14341434
e->counters.wal_records += walusage->wal_records;
1435-
e->counters.wal_fpw += walusage->wal_fpw;
1435+
e->counters.wal_fpi += walusage->wal_fpi;
14361436
e->counters.wal_bytes += walusage->wal_bytes;
14371437

14381438
SpinLockRelease(&e->mutex);
@@ -1824,7 +1824,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
18241824
Datum wal_bytes;
18251825

18261826
values[i++] = Int64GetDatumFast(tmp.wal_records);
1827-
values[i++] = Int64GetDatumFast(tmp.wal_fpw);
1827+
values[i++] = Int64GetDatumFast(tmp.wal_fpi);
18281828

18291829
snprintf(buf, sizeof buf, UINT64_FORMAT, tmp.wal_bytes);
18301830

doc/src/sgml/pgstatstatements.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@
283283
</row>
284284

285285
<row>
286-
<entry><structfield>wal_fpw</structfield></entry>
286+
<entry><structfield>wal_fpi</structfield></entry>
287287
<entry><type>bigint</type></entry>
288288
<entry></entry>
289289
<entry>
290-
Total number of WAL full page writes generated by the statement
290+
Total number of WAL full page images generated by the statement
291291
</entry>
292292
</row>
293293

doc/src/sgml/ref/explain.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ ROLLBACK;
198198
<listitem>
199199
<para>
200200
Include information on WAL record generation. Specifically, include the
201-
number of records, number of full page writes and amount of WAL bytes
202-
generated. In text format, only non-zero values are printed. This
201+
number of records, number of full page images (fpi) and amount of WAL
202+
bytes generated. In text format, only non-zero values are printed. This
203203
parameter may only be used when <literal>ANALYZE</literal> is also
204204
enabled. It defaults to <literal>FALSE</literal>.
205205
</para>

src/backend/access/heap/vacuumlazy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,10 @@ heap_vacuum_rel(Relation onerel, VacuumParams *params,
673673
read_rate, write_rate);
674674
appendStringInfo(&buf, _("system usage: %s\n"), pg_rusage_show(&ru0));
675675
appendStringInfo(&buf,
676-
_("WAL usage: %ld records, %ld full page writes, "
676+
_("WAL usage: %ld records, %ld full page images, "
677677
UINT64_FORMAT " bytes"),
678678
walusage.wal_records,
679-
walusage.wal_fpw,
679+
walusage.wal_fpi,
680680
walusage.wal_bytes);
681681

682682
ereport(LOG,

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ XLogRecPtr
998998
XLogInsertRecord(XLogRecData *rdata,
999999
XLogRecPtr fpw_lsn,
10001000
uint8 flags,
1001-
int num_fpw)
1001+
int num_fpi)
10021002
{
10031003
XLogCtlInsert *Insert = &XLogCtl->Insert;
10041004
pg_crc32c rdata_crc;
@@ -1259,7 +1259,7 @@ XLogInsertRecord(XLogRecData *rdata,
12591259
{
12601260
pgWalUsage.wal_bytes += rechdr->xl_tot_len;
12611261
pgWalUsage.wal_records++;
1262-
pgWalUsage.wal_fpw += num_fpw;
1262+
pgWalUsage.wal_fpi += num_fpi;
12631263
}
12641264

12651265
return EndPos;

src/backend/access/transam/xloginsert.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static MemoryContext xloginsert_cxt;
109109

110110
static XLogRecData *XLogRecordAssemble(RmgrId rmid, uint8 info,
111111
XLogRecPtr RedoRecPtr, bool doPageWrites,
112-
XLogRecPtr *fpw_lsn, int *num_fpw);
112+
XLogRecPtr *fpw_lsn, int *num_fpi);
113113
static bool XLogCompressBackupBlock(char *page, uint16 hole_offset,
114114
uint16 hole_length, char *dest, uint16 *dlen);
115115

@@ -449,7 +449,7 @@ XLogInsert(RmgrId rmid, uint8 info)
449449
bool doPageWrites;
450450
XLogRecPtr fpw_lsn;
451451
XLogRecData *rdt;
452-
int num_fpw = 0;
452+
int num_fpi = 0;
453453

454454
/*
455455
* Get values needed to decide whether to do full-page writes. Since
@@ -459,9 +459,9 @@ XLogInsert(RmgrId rmid, uint8 info)
459459
GetFullPageWriteInfo(&RedoRecPtr, &doPageWrites);
460460

461461
rdt = XLogRecordAssemble(rmid, info, RedoRecPtr, doPageWrites,
462-
&fpw_lsn, &num_fpw);
462+
&fpw_lsn, &num_fpi);
463463

464-
EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpw);
464+
EndPos = XLogInsertRecord(rdt, fpw_lsn, curinsert_flags, num_fpi);
465465
} while (EndPos == InvalidXLogRecPtr);
466466

467467
XLogResetInsertion();
@@ -484,7 +484,7 @@ XLogInsert(RmgrId rmid, uint8 info)
484484
static XLogRecData *
485485
XLogRecordAssemble(RmgrId rmid, uint8 info,
486486
XLogRecPtr RedoRecPtr, bool doPageWrites,
487-
XLogRecPtr *fpw_lsn, int *num_fpw)
487+
XLogRecPtr *fpw_lsn, int *num_fpi)
488488
{
489489
XLogRecData *rdt;
490490
uint32 total_len = 0;
@@ -638,7 +638,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
638638
bkpb.fork_flags |= BKPBLOCK_HAS_IMAGE;
639639

640640
/* Report a full page image constructed for the WAL record */
641-
*num_fpw += 1;
641+
*num_fpi += 1;
642642

643643
/*
644644
* Construct XLogRecData entries for the page content.

src/backend/commands/explain.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,31 +3343,31 @@ show_wal_usage(ExplainState *es, const WalUsage *usage)
33433343
if (es->format == EXPLAIN_FORMAT_TEXT)
33443344
{
33453345
/* Show only positive counter values. */
3346-
if ((usage->wal_records > 0) || (usage->wal_fpw > 0) ||
3346+
if ((usage->wal_records > 0) || (usage->wal_fpi > 0) ||
33473347
(usage->wal_bytes > 0))
33483348
{
33493349
ExplainIndentText(es);
33503350
appendStringInfoString(es->str, "WAL:");
33513351

33523352
if (usage->wal_records > 0)
3353-
appendStringInfo(es->str, " records=%ld",
3353+
appendStringInfo(es->str, " records=%ld",
33543354
usage->wal_records);
3355-
if (usage->wal_fpw > 0)
3356-
appendStringInfo(es->str, " full page writes=%ld",
3357-
usage->wal_fpw);
3355+
if (usage->wal_fpi > 0)
3356+
appendStringInfo(es->str, " fpi=%ld",
3357+
usage->wal_fpi);
33583358
if (usage->wal_bytes > 0)
3359-
appendStringInfo(es->str, " bytes=" UINT64_FORMAT,
3359+
appendStringInfo(es->str, " bytes=" UINT64_FORMAT,
33603360
usage->wal_bytes);
33613361
appendStringInfoChar(es->str, '\n');
33623362
}
33633363
}
33643364
else
33653365
{
3366-
ExplainPropertyInteger("WAL records", NULL,
3366+
ExplainPropertyInteger("WAL Records", NULL,
33673367
usage->wal_records, es);
3368-
ExplainPropertyInteger("WAL full page writes", NULL,
3369-
usage->wal_fpw, es);
3370-
ExplainPropertyUInteger("WAL bytes", NULL,
3368+
ExplainPropertyInteger("WAL FPI", NULL,
3369+
usage->wal_fpi, es);
3370+
ExplainPropertyUInteger("WAL Bytes", NULL,
33713371
usage->wal_bytes, es);
33723372
}
33733373
}

src/backend/executor/instrument.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ WalUsageAdd(WalUsage *dst, WalUsage *add)
248248
{
249249
dst->wal_bytes += add->wal_bytes;
250250
dst->wal_records += add->wal_records;
251-
dst->wal_fpw += add->wal_fpw;
251+
dst->wal_fpi += add->wal_fpi;
252252
}
253253

254254
void
255255
WalUsageAccumDiff(WalUsage *dst, const WalUsage *add, const WalUsage *sub)
256256
{
257257
dst->wal_bytes += add->wal_bytes - sub->wal_bytes;
258258
dst->wal_records += add->wal_records - sub->wal_records;
259-
dst->wal_fpw += add->wal_fpw - sub->wal_fpw;
259+
dst->wal_fpi += add->wal_fpi - sub->wal_fpi;
260260
}

src/include/access/xlog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ struct XLogRecData;
280280
extern XLogRecPtr XLogInsertRecord(struct XLogRecData *rdata,
281281
XLogRecPtr fpw_lsn,
282282
uint8 flags,
283-
int num_fpw);
283+
int num_fpi);
284284
extern void XLogFlush(XLogRecPtr RecPtr);
285285
extern bool XLogBackgroundFlush(void);
286286
extern bool XLogNeedsFlush(XLogRecPtr RecPtr);

src/include/executor/instrument.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef struct BufferUsage
3535
typedef struct WalUsage
3636
{
3737
long wal_records; /* # of WAL records produced */
38-
long wal_fpw; /* # of WAL full page writes produced */
38+
long wal_fpi; /* # of WAL full page images produced */
3939
uint64 wal_bytes; /* size of WAL records produced */
4040
} WalUsage;
4141

0 commit comments

Comments
 (0)