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

Commit0e42d31

Browse files
committed
Adding new PgStat_WalCounters structure in pgstat.h
This new structure contains the counters and the data related to the WALactivity statistics gathered from WalUsage, separated into its ownstructure so as it can be shared across more than one Stats structure inpg_stat.h.This refactoring will be used by an upcoming patch introducingbackend-level WAL statistics.Bump PGSTAT_FILE_FORMAT_ID.Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Discussion:https://postgr.es/m/Z3zqc4o09dM/Ezyz@ip-10-97-1-34.eu-west-3.compute.internal
1 parentd7cbeaf commit0e42d31

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

‎src/backend/utils/activity/pgstat_wal.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pgstat_wal_flush_cb(bool nowait)
106106
return true;
107107

108108
#defineWALSTAT_ACC(fld,var_to_add) \
109-
(stats_shmem->stats.fld += var_to_add.fld)
109+
(stats_shmem->stats.wal_counters.fld += var_to_add.fld)
110110
WALSTAT_ACC(wal_records,wal_usage_diff);
111111
WALSTAT_ACC(wal_fpi,wal_usage_diff);
112112
WALSTAT_ACC(wal_bytes,wal_usage_diff);

‎src/backend/utils/adt/pgstatfuncs.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,6 +1643,7 @@ pg_stat_get_wal(PG_FUNCTION_ARGS)
16431643
boolnulls[PG_STAT_GET_WAL_COLS]= {0};
16441644
charbuf[256];
16451645
PgStat_WalStats*wal_stats;
1646+
PgStat_WalCounterswal_counters;
16461647

16471648
/* Initialise attributes information in the tuple descriptor */
16481649
tupdesc=CreateTemplateTupleDesc(PG_STAT_GET_WAL_COLS);
@@ -1661,19 +1662,20 @@ pg_stat_get_wal(PG_FUNCTION_ARGS)
16611662

16621663
/* Get statistics about WAL activity */
16631664
wal_stats=pgstat_fetch_stat_wal();
1665+
wal_counters=wal_stats->wal_counters;
16641666

16651667
/* Fill values and NULLs */
1666-
values[0]=Int64GetDatum(wal_stats->wal_records);
1667-
values[1]=Int64GetDatum(wal_stats->wal_fpi);
1668+
values[0]=Int64GetDatum(wal_counters.wal_records);
1669+
values[1]=Int64GetDatum(wal_counters.wal_fpi);
16681670

16691671
/* Convert to numeric. */
1670-
snprintf(buf,sizeofbuf,UINT64_FORMAT,wal_stats->wal_bytes);
1672+
snprintf(buf,sizeofbuf,UINT64_FORMAT,wal_counters.wal_bytes);
16711673
values[2]=DirectFunctionCall3(numeric_in,
16721674
CStringGetDatum(buf),
16731675
ObjectIdGetDatum(0),
16741676
Int32GetDatum(-1));
16751677

1676-
values[3]=Int64GetDatum(wal_stats->wal_buffers_full);
1678+
values[3]=Int64GetDatum(wal_counters.wal_buffers_full);
16771679

16781680
values[4]=TimestampTzGetDatum(wal_stats->stat_reset_timestamp);
16791681

‎src/include/pgstat.h‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ typedef struct PgStat_TableXactStatus
212212
* ------------------------------------------------------------
213213
*/
214214

215-
#definePGSTAT_FILE_FORMAT_ID0x01A5BCB4
215+
#definePGSTAT_FILE_FORMAT_ID0x01A5BCB5
216216

217217
typedefstructPgStat_ArchiverStats
218218
{
@@ -474,12 +474,29 @@ typedef struct PgStat_StatTabEntry
474474
PgStat_Countertotal_autoanalyze_time;
475475
}PgStat_StatTabEntry;
476476

477-
typedefstructPgStat_WalStats
477+
/* ------
478+
* PgStat_WalCountersWAL activity data gathered from WalUsage
479+
*
480+
* This stores all the counters and data gathered from WalUsage for WAL
481+
* activity statistics, separated into its own structure so as this can be
482+
* shared across multiple Stats structures.
483+
* ------
484+
*/
485+
typedefstructPgStat_WalCounters
478486
{
479487
PgStat_Counterwal_records;
480488
PgStat_Counterwal_fpi;
481489
uint64wal_bytes;
482490
PgStat_Counterwal_buffers_full;
491+
}PgStat_WalCounters;
492+
493+
/* -------
494+
* PgStat_WalStatsWAL statistics
495+
* -------
496+
*/
497+
typedefstructPgStat_WalStats
498+
{
499+
PgStat_WalCounterswal_counters;
483500
TimestampTzstat_reset_timestamp;
484501
}PgStat_WalStats;
485502

‎src/tools/pgindent/typedefs.list‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ PgStat_SubXactStatus
21892189
PgStat_TableCounts
21902190
PgStat_TableStatus
21912191
PgStat_TableXactStatus
2192+
PgStat_WalCounters
21922193
PgStat_WalStats
21932194
PgXmlErrorContext
21942195
PgXmlStrictness

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp