29 #define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat" 30 #define PGSTAT_STAT_PERMANENT_FILENAME "pg_stat/global.stat" 31 #define PGSTAT_STAT_PERMANENT_TMPFILE "pg_stat/global.tmp" 34 #define PG_STAT_TMP_DIR "pg_stat_tmp" 224 #define PGSTAT_MAX_MSG_SIZE 1000 225 #define PGSTAT_MSG_PAYLOAD (PGSTAT_MAX_MSG_SIZE - sizeof(PgStat_MsgHdr)) 281 #define PGSTAT_NUM_TABENTRIES \ 282 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - 3 * sizeof(int) - 2 * sizeof(PgStat_Counter)) \ 283 / sizeof(PgStat_TableEntry)) 303 #define PGSTAT_NUM_TABPURGE \ 304 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \ 583 #define PGSTAT_NUM_FUNCENTRIES \ 584 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \ 585 / sizeof(PgStat_FunctionEntry)) 600 #define PGSTAT_NUM_FUNCPURGE \ 601 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \ 695 #define PGSTAT_FILE_FORMAT_ID 0x01A5BCA0 895 #define PG_WAIT_LWLOCK 0x01000000U 896 #define PG_WAIT_LOCK 0x03000000U 897 #define PG_WAIT_BUFFER_PIN 0x04000000U 898 #define PG_WAIT_ACTIVITY 0x05000000U 899 #define PG_WAIT_CLIENT 0x06000000U 900 #define PG_WAIT_EXTENSION 0x07000000U 901 #define PG_WAIT_IPC 0x08000000U 902 #define PG_WAIT_TIMEOUT 0x09000000U 903 #define PG_WAIT_IO 0x0A000000U 1118 #define PGSTAT_NUM_PROGRESS_PARAM 20 1286 #define PGSTAT_BEGIN_WRITE_ACTIVITY(beentry) \ 1288 START_CRIT_SECTION(); \ 1289 (beentry)->st_changecount++; \ 1290 pg_write_barrier(); \ 1293 #define PGSTAT_END_WRITE_ACTIVITY(beentry) \ 1295 pg_write_barrier(); \ 1296 (beentry)->st_changecount++; \ 1297 Assert(((beentry)->st_changecount & 1) == 0); \ 1298 END_CRIT_SECTION(); \ 1301 #define pgstat_begin_read_activity(beentry, before_changecount) \ 1303 (before_changecount) = (beentry)->st_changecount; \ 1304 pg_read_barrier(); \ 1307 #define pgstat_end_read_activity(beentry, after_changecount) \ 1309 pg_read_barrier(); \ 1310 (after_changecount) = (beentry)->st_changecount; \ 1313 #define pgstat_read_activity_complete(before_changecount, after_changecount) \ 1314 ((before_changecount) == (after_changecount) && \ 1315 ((before_changecount) & 1) == 0) 1442 int spillbytes,
int streamtxns,
int streamcount,
int streambytes);
1528 #define pgstat_count_heap_scan(rel) \ 1530 if ((rel)->pgstat_info != NULL) \ 1531 (rel)->pgstat_info->t_counts.t_numscans++; \ 1533 #define pgstat_count_heap_getnext(rel) \ 1535 if ((rel)->pgstat_info != NULL) \ 1536 (rel)->pgstat_info->t_counts.t_tuples_returned++; \ 1538 #define pgstat_count_heap_fetch(rel) \ 1540 if ((rel)->pgstat_info != NULL) \ 1541 (rel)->pgstat_info->t_counts.t_tuples_fetched++; \ 1543 #define pgstat_count_index_scan(rel) \ 1545 if ((rel)->pgstat_info != NULL) \ 1546 (rel)->pgstat_info->t_counts.t_numscans++; \ 1548 #define pgstat_count_index_tuples(rel, n) \ 1550 if ((rel)->pgstat_info != NULL) \ 1551 (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \ 1553 #define pgstat_count_buffer_read(rel) \ 1555 if ((rel)->pgstat_info != NULL) \ 1556 (rel)->pgstat_info->t_counts.t_blocks_fetched++; \ 1558 #define pgstat_count_buffer_hit(rel) \ 1560 if ((rel)->pgstat_info != NULL) \ 1561 (rel)->pgstat_info->t_counts.t_blocks_hit++; \ 1563 #define pgstat_count_buffer_read_time(n) \ 1564 (pgStatBlockReadTime += (n)) 1565 #define pgstat_count_buffer_write_time(n) \ 1566 (pgStatBlockWriteTime += (n)) 1587 void *recdata,
uint32 len);
1589 void *recdata,
uint32 len);
void pgstat_report_checksum_failure(void)
struct PgBackendGSSStatus PgBackendGSSStatus
void pgstat_count_truncate(Relation rel)
PgStat_MsgResetslrucounter msg_resetslrucounter
PgStat_MsgAutovacStart msg_autovacuum_start
PgStat_MsgBgWriter msg_bgwriter
PgStat_Counter m_buf_fsync_backend
PgStat_ArchiverStats * pgstat_fetch_stat_archiver(void)
void pgstat_initialize(void)
PgStat_Counter analyze_count
#define pg_attribute_noreturn()
PgStat_Counter archived_count
PgStat_Counter m_buf_written_checkpoints
PgStat_Counter m_buf_alloc
struct PgStat_MsgFuncpurge PgStat_MsgFuncpurge
PgStat_Counter t_delta_live_tuples
Oid st_progress_command_target
PgStat_Counter m_dead_tuples
void pgstat_clear_snapshot(void)
PgStat_Counter stream_count
PgStat_Counter wal_records
PgStat_Counter m_checkpoint_write_time
PgStat_Counter tuples_updated
void pgstat_report_xact_timestamp(TimestampTz tstamp)
const char * pgstat_get_backend_current_activity(int pid, bool checkUser)
TimestampTz stat_reset_timestamp
NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn()
struct PgStat_MsgResetreplslotcounter PgStat_MsgResetreplslotcounter
PgStat_Counter tuples_returned
PgStat_MsgDeadlock msg_deadlock
void pgstat_count_slru_page_exists(int slru_idx)
PgStat_MsgResetsharedcounter msg_resetsharedcounter
union PgStat_Msg PgStat_Msg
TimestampTz stats_timestamp
void pgstat_progress_update_param(int index, int64 val)
PgStat_Counter t_tuples_fetched
PgStat_MsgChecksumFailure msg_checksumfailure
PgStat_Counter m_live_tuples
void pgstat_count_slru_page_written(int slru_idx)
TimestampTz st_activity_start_timestamp
PgStat_Counter n_blocks_hit
void pgstat_send_wal(void)
#define PGSTAT_NUM_TABPURGE
struct PgStat_MsgTabpurge PgStat_MsgTabpurge
void pgstat_update_heap_dead_tuples(Relation rel, int delta)
struct PgStat_MsgArchiver PgStat_MsgArchiver
PgStat_Counter m_timed_checkpoints
PgStat_Counter n_conflict_bufferpin
void pgstat_report_appname(const char *appname)
PgStat_Counter m_maxwritten_clean
PgStat_Counter n_conflict_startup_deadlock
void CreateSharedBackendStatus(void)
PgStat_Counter t_tuples_hot_updated
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
TimestampTz autovac_analyze_timestamp
struct PgStat_MsgDeadlock PgStat_MsgDeadlock
struct timeval instr_time
PgStat_Counter f_self_time
PgStat_Counter timed_checkpoints
TimestampTz stat_reset_timestamp
PgStat_Counter n_checksum_failures
TimestampTz stat_reset_timestamp
PgStat_Counter n_temp_files
PgStat_Counter m_buf_written_clean
PgStat_MsgDummy msg_dummy
TimestampTz last_checksum_failure
PgStat_Counter m_spill_bytes
TransactionId backend_xmin
PgStat_Counter m_active_time
PgStat_GlobalStats * pgstat_fetch_global(void)
void pgstat_reset_replslot_counter(const char *name)
PgStat_SLRUStats * pgstat_fetch_slru(void)
PgStat_Counter n_tuples_returned
struct PgStat_MsgReplSlot PgStat_MsgReplSlot
PgStat_Counter vacuum_count
void pgstat_send_archiver(const char *xlog, bool failed)
PgStat_MsgTempFile msg_tempfile
PgStat_Counter buf_fsync_backend
struct PgStat_TableCounts PgStat_TableCounts
struct PgStat_MsgDummy PgStat_MsgDummy
TimestampTz stats_timestamp
PgStat_Counter spill_txns
TimestampTz stat_reset_timestamp
void pgstat_reset_slru_counter(const char *)
struct PgStat_TableXactStatus * next
struct PgStat_ReplSlotStats PgStat_ReplSlotStats
TimestampTz m_analyzetime
ProgressCommandType st_progress_command
void pgstat_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
PgStat_TableCounts t_counts
PgStat_Counter blocks_exists
struct PgBackendSSLStatus PgBackendSSLStatus
struct PgStat_MsgRecoveryConflict PgStat_MsgRecoveryConflict
Datum ssl_client_serial(PG_FUNCTION_ARGS)
struct PgStat_ArchiverStats PgStat_ArchiverStats
PgStat_Counter deleted_pre_trunc
PgStat_Counter m_blocks_exists
PgStat_MsgAnalyze msg_analyze
PgStat_Counter tuples_hot_updated
PgStat_Counter f_total_time
PgStat_Counter spill_bytes
PgStat_Counter t_tuples_returned
PgStat_Shared_Reset_Target
PgStat_Counter tuples_inserted
PgStat_FunctionCounts * fs
PgStat_Counter f_numcalls
struct PgStat_StatFuncEntry PgStat_StatFuncEntry
struct PgStat_FunctionCallUsage PgStat_FunctionCallUsage
struct PgStat_SLRUStats PgStat_SLRUStats
PgStat_Counter m_stream_bytes
PgStat_StatTabEntry * pgstat_fetch_stat_tabentry(Oid relid)
PgStat_Counter n_xact_commit
void pgstat_report_deadlock(void)
PgStat_Counter stream_bytes
PgStat_MsgBgWriter BgWriterStats
void pgstat_report_replslot(const char *slotname, int spilltxns, int spillcount, int spillbytes, int streamtxns, int streamcount, int streambytes)
#define PGSTAT_NUM_PROGRESS_PARAM
PgStat_Counter n_blocks_fetched
PgStat_Counter n_sessions_killed
struct PgStat_TableEntry PgStat_TableEntry
const char * pgstat_slru_name(int slru_idx)
PgStat_Counter n_live_tuples
PgStat_Counter m_requested_checkpoints
PgStat_Counter inserts_since_vacuum
struct PgStat_MsgAnalyze PgStat_MsgAnalyze
PgStat_FunctionCounts f_counts
PgStat_TableStatus * find_tabstat_entry(Oid rel_id)
PgStat_MsgFuncpurge msg_funcpurge
char * pgstat_stat_tmpname
PgStat_Counter buf_written_backend
PgStat_Counter n_conflict_tablespace
PgStat_Counter m_spill_txns
TransactionId backend_xid
void AtEOSubXact_PgStat(bool isCommit, int nestDepth)
TimestampTz vacuum_timestamp
PgStat_Counter t_tuples_updated
PgStat_Counter total_active_time
PgStat_Counter pgStatBlockReadTime
void pgstat_reset_single_counter(Oid objectid, PgStat_Single_Reset_Type type)
PgStat_Counter checkpoint_write_time
PgStat_Counter n_sessions_abandoned
PgStat_Counter n_dead_tuples
TimestampTz m_failure_time
struct PgStat_MsgTempFile PgStat_MsgTempFile
LocalPgBackendStatus * pgstat_fetch_stat_local_beentry(int beid)
void allow_immediate_pgstat_restart(void)
PgStat_Counter f_numcalls
TimestampTz last_autovac_time
struct PgStat_GlobalStats PgStat_GlobalStats
void pgstat_count_slru_page_read(int slru_idx)
PgStat_Counter m_blocks_written
PgStat_Counter n_sessions_fatal
PgStat_Counter n_tuples_inserted
PgStat_Counter buf_written_checkpoints
PgStat_Counter tuples_inserted
struct PgStat_MsgDropdb PgStat_MsgDropdb
PgStat_Counter pgStatBlockWriteTime
struct PgStat_MsgSLRU PgStat_MsgSLRU
struct PgStat_MsgInquiry PgStat_MsgInquiry
void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
char * pgstat_stat_directory
PgStat_Counter blocks_read
PgStat_Counter total_idle_in_xact_time
void pgstat_report_stat(bool force)
void pgstat_vacuum_stat(void)
PgStat_Counter t_delta_dead_tuples
PgStat_Counter tuples_fetched
void pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
PgStat_Counter n_conflict_snapshot
PgStat_Counter m_block_write_time
static void pgstat_report_wait_end(void)
TimestampTz st_state_start_timestamp
PgStat_Counter n_tuples_deleted
void pgstat_twophase_postabort(TransactionId xid, uint16 info, void *recdata, uint32 len)
PgStat_Counter n_conflict_lock
PgStat_Counter blocks_hit
PgStat_Counter total_session_time
PgStat_Counter t_blocks_hit
struct PgStat_WalStats PgStat_WalStats
struct PgStat_TableXactStatus * upper
PgStat_Counter n_xact_rollback
PgStat_Counter m_wal_buffers_full
SessionEndType pgStatSessionEndCause
void pgstat_progress_end_command(void)
PgStat_Counter t_tuples_deleted
PgStat_Counter buf_written_clean
Datum ssl_issuer_dn(PG_FUNCTION_ARGS)
int pgstat_fetch_stat_numbackends(void)
void AtEOXact_PgStat(bool isCommit, bool parallel)
void pgstat_report_recovery_conflict(int reason)
PgStat_Counter blocks_zeroed
PgStat_MsgRecoveryConflict msg_recoveryconflict
struct PgStat_MsgTabstat PgStat_MsgTabstat
PgBackendStatus * pgstat_fetch_stat_beentry(int beid)
PgStat_Counter m_idle_in_xact_time
PgStat_Counter m_live_tuples
void pgstat_drop_database(Oid databaseid)
void pgstat_count_slru_truncate(int slru_idx)
const char * pgstat_get_wait_event_type(uint32 wait_event_info)
struct PgStat_MsgResetsharedcounter PgStat_MsgResetsharedcounter
struct PgStat_FunctionCounts PgStat_FunctionCounts
const char * pgstat_get_wait_event(uint32 wait_event_info)
PgBackendStatus backendStatus
#define PGSTAT_NUM_FUNCENTRIES
PgStat_Counter tuples_deleted
struct PgStat_MsgBgWriter PgStat_MsgBgWriter
#define PGSTAT_NUM_TABENTRIES
struct PgStat_MsgResetsinglecounter PgStat_MsgResetsinglecounter
void pgstat_reset_counters(void)
BackendType st_backendType
PgStat_Counter f_total_time
PgStat_Counter blocks_hit
TimestampTz analyze_timestamp
TimestampTz last_failed_timestamp
PgStat_Counter changes_since_analyze
PgStat_Shared_Reset_Target m_resettarget
void pgstat_report_vacuum(Oid tableoid, bool shared, PgStat_Counter livetuples, PgStat_Counter deadtuples)
PgStat_Counter t_numscans
struct PgStat_MsgVacuum PgStat_MsgVacuum
Size BackendStatusShmemSize(void)
struct PgStat_TableXactStatus PgStat_TableXactStatus
Datum ssl_version(PG_FUNCTION_ARGS)
PGDLLIMPORT bool pgstat_track_counts
PgStat_Counter n_tuples_updated
Datum ssl_client_dn(PG_FUNCTION_ARGS)
PgStat_Counter m_stream_txns
void pgstat_report_replslot_drop(const char *slotname)
char * pgstat_stat_filename
PgStat_Counter t_changed_tuples
struct PgStat_MsgWal PgStat_MsgWal
PgStat_MsgTabstat msg_tabstat
void pgstat_send_bgwriter(void)
struct PgStat_MsgChecksumFailure PgStat_MsgChecksumFailure
PgStat_Counter m_checkpoint_sync_time
PgStat_MsgVacuum msg_vacuum
PgStat_Counter n_sessions
PgStat_Counter failed_count
PgStat_StatDBEntry * pgstat_fetch_stat_dbentry(Oid dbid)
PgStat_Counter n_block_write_time
PgStat_Counter m_buf_written_backend
PgStat_Counter m_blocks_read
void pgstat_count_heap_delete(Relation rel)
PgStat_Counter tuples_deleted
struct PgStat_StatTabEntry PgStat_StatTabEntry
PgStat_TableCounts t_counts
void pgstat_count_slru_flush(int slru_idx)
PgStat_Counter inserted_pre_trunc
PgStat_Counter tuples_updated
PgStat_Counter checkpoint_sync_time
PgStat_Counter m_spill_count
static void pgstat_report_wait_start(uint32 wait_event_info)
void pgstat_report_tempfile(size_t filesize)
PGDLLIMPORT bool pgstat_track_activities
struct PgStat_FunctionEntry PgStat_FunctionEntry
TimestampTz autovac_vacuum_timestamp
PgStat_Counter maxwritten_clean
PgStat_Counter n_block_read_time
PgStat_Counter m_block_read_time
struct PgStat_MsgFuncstat PgStat_MsgFuncstat
TimestampTz stat_reset_timestamp
void pgstat_bestart(void)
struct PgStat_TableXactStatus * trans
struct PgStat_TableStatus PgStat_TableStatus
PgStat_MsgResetreplslotcounter msg_resetreplslotcounter
struct PgBackendStatus PgBackendStatus
struct PgStat_StatDBEntry PgStat_StatDBEntry
PgStat_Counter autovac_analyze_count
void pgstat_report_autovac(Oid dboid)
int pgstat_slru_index(const char *name)
PgStat_Counter updated_pre_trunc
void pgstat_count_slru_page_hit(int slru_idx)
void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
void pgstat_report_activity(BackendState state, const char *cmd_str)
void pgstat_count_heap_update(Relation rel, bool hot)
PgStat_BackendFunctionEntry * find_funcstat_entry(Oid func_id)
void pgstat_init_function_usage(struct FunctionCallInfoBaseData *fcinfo, PgStat_FunctionCallUsage *fcu)
PgStat_Counter m_session_time
Datum ssl_cipher(PG_FUNCTION_ARGS)
TimestampTz stat_reset_timestamp
TimestampTz last_archived_timestamp
PgStat_Counter n_deadlocks
struct PgStat_MsgConn PgStat_MsgConn
struct PgStat_MsgResetslrucounter PgStat_MsgResetslrucounter
struct PgStat_MsgAutovacStart PgStat_MsgAutovacStart
TimestampTz st_xact_start_timestamp
PgStat_MsgArchiver msg_archiver
const char * pgstat_get_crashed_backend_activity(int pid, char *buffer, int buflen)
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter)
PgStat_MsgResetsinglecounter msg_resetsinglecounter
PgStat_Counter requested_checkpoints
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
PgStat_StatFuncEntry * pgstat_fetch_stat_funcentry(Oid funcid)
instr_time save_f_total_time
PgStat_MsgResetcounter msg_resetcounter
void pgstat_reset_all(void)
PgStat_WalStats * pgstat_fetch_stat_wal(void)
PgStat_Counter m_stream_count
PgStat_Counter m_blocks_zeroed
PgStat_MsgReplSlot msg_replslot
PgStat_Counter f_numcalls
struct PgStat_MsgResetcounter PgStat_MsgResetcounter
PgStat_Counter wal_buffers_full
PgStat_Counter f_self_time
PgStat_Counter m_dead_tuples
PgStat_ReplSlotStats * pgstat_fetch_replslot(int *nslots_p)
PgStat_Counter blocks_fetched
PgStat_Counter m_truncate
void AtPrepare_PgStat(void)
struct PgStat_BackendFunctionEntry PgStat_BackendFunctionEntry
struct PgStat_MsgHdr PgStat_MsgHdr
TimestampTz st_proc_start_timestamp
PgStat_MsgInquiry msg_inquiry
PgStat_MsgDropdb msg_dropdb
PgBackendSSLStatus * st_sslstatus
PgStat_Single_Reset_Type m_resettype
void pgstat_initstats(Relation rel)
void pgstat_count_slru_page_zeroed(int slru_idx)
PgStat_Counter t_tuples_inserted
void pgstat_reset_shared_counters(const char *)
PgStat_Counter spill_count
char * pgstat_clip_activity(const char *raw_activity)
PgStat_Counter blocks_written
PgStat_MsgTabpurge msg_tabpurge
#define PGSTAT_NUM_FUNCPURGE
PGDLLIMPORT int pgstat_track_activity_query_size
PgBackendGSSStatus * st_gssstatus
PgStat_TableStatus * parent
PGDLLIMPORT int pgstat_track_functions
PgStat_Counter t_blocks_fetched
void PostPrepare_PgStat(void)
PgStat_MsgFuncstat msg_funcstat
struct LocalPgBackendStatus LocalPgBackendStatus
PgStat_Counter m_blocks_hit
PgStat_Counter n_tuples_fetched
PgStat_Counter autovac_vacuum_count
PgStat_Counter m_wal_records
SessionEndType m_disconnect
PgStat_Counter n_temp_bytes
PgStat_Counter stream_txns