28 #define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat" 29 #define PGSTAT_STAT_PERMANENT_FILENAME "pg_stat/global.stat" 30 #define PGSTAT_STAT_PERMANENT_TMPFILE "pg_stat/global.tmp" 33 #define PG_STAT_TMP_DIR "pg_stat_tmp" 238 #define PGSTAT_MAX_MSG_SIZE 1000 239 #define PGSTAT_MSG_PAYLOAD (PGSTAT_MAX_MSG_SIZE - sizeof(PgStat_MsgHdr)) 295 #define PGSTAT_NUM_TABENTRIES \ 296 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - 3 * sizeof(int) - 2 * sizeof(PgStat_Counter)) \ 297 / sizeof(PgStat_TableEntry)) 317 #define PGSTAT_NUM_TABPURGE \ 318 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \ 454 #define PGSTAT_NUM_ANCESTORENTRIES \ 455 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(Oid) - sizeof(int)) \ 633 #define PGSTAT_NUM_FUNCENTRIES \ 634 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \ 635 / sizeof(PgStat_FunctionEntry)) 650 #define PGSTAT_NUM_FUNCPURGE \ 651 ((PGSTAT_MSG_PAYLOAD - sizeof(Oid) - sizeof(int)) \ 747 #define PGSTAT_FILE_FORMAT_ID 0x01A5BCA2 1047 #define pgstat_count_heap_scan(rel) \ 1049 if ((rel)->pgstat_info != NULL) \ 1050 (rel)->pgstat_info->t_counts.t_numscans++; \ 1052 #define pgstat_count_heap_getnext(rel) \ 1054 if ((rel)->pgstat_info != NULL) \ 1055 (rel)->pgstat_info->t_counts.t_tuples_returned++; \ 1057 #define pgstat_count_heap_fetch(rel) \ 1059 if ((rel)->pgstat_info != NULL) \ 1060 (rel)->pgstat_info->t_counts.t_tuples_fetched++; \ 1062 #define pgstat_count_index_scan(rel) \ 1064 if ((rel)->pgstat_info != NULL) \ 1065 (rel)->pgstat_info->t_counts.t_numscans++; \ 1067 #define pgstat_count_index_tuples(rel, n) \ 1069 if ((rel)->pgstat_info != NULL) \ 1070 (rel)->pgstat_info->t_counts.t_tuples_returned += (n); \ 1072 #define pgstat_count_buffer_read(rel) \ 1074 if ((rel)->pgstat_info != NULL) \ 1075 (rel)->pgstat_info->t_counts.t_blocks_fetched++; \ 1077 #define pgstat_count_buffer_hit(rel) \ 1079 if ((rel)->pgstat_info != NULL) \ 1080 (rel)->pgstat_info->t_counts.t_blocks_hit++; \ 1082 #define pgstat_count_buffer_read_time(n) \ 1083 (pgStatBlockReadTime += (n)) 1084 #define pgstat_count_buffer_write_time(n) \ 1085 (pgStatBlockWriteTime += (n)) 1086 #define pgstat_count_conn_active_time(n) \ 1087 (pgStatActiveTime += (n)) 1088 #define pgstat_count_conn_txn_idle_time(n) \ 1089 (pgStatTransactionIdleTime += (n)) 1110 void *recdata,
uint32 len);
1112 void *recdata,
uint32 len);
void pgstat_report_checksum_failure(void)
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
PgStat_Counter m_dead_tuples
void pgstat_clear_snapshot(void)
PgStat_Counter stream_count
PgStat_Counter wal_records
PgStat_Counter total_txns
PgStat_Counter m_checkpoint_write_time
PgStat_Counter tuples_updated
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
PgStat_Counter t_tuples_fetched
PgStat_MsgChecksumFailure msg_checksumfailure
PgStat_Counter m_live_tuples
void pgstat_count_slru_page_written(int slru_idx)
PgStat_MsgRecoveryPrefetch msg_recoveryprefetch
PgStat_Counter n_blocks_hit
#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
PgStat_Counter m_maxwritten_clean
PgStat_Counter n_conflict_startup_deadlock
PgStat_Counter t_tuples_hot_updated
TimestampTz autovac_analyze_timestamp
PgStat_Counter wal_sync_time
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
struct PgStat_RecoveryPrefetchStats PgStat_RecoveryPrefetchStats
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_wal_sync
PgStat_Counter m_spill_bytes
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
struct PgStat_MsgAnlAncestors PgStat_MsgAnlAncestors
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
void pgstat_twophase_postcommit(TransactionId xid, uint16 info, void *recdata, uint32 len)
PgStat_TableCounts t_counts
PgStat_Counter blocks_exists
struct PgStat_MsgRecoveryConflict PgStat_MsgRecoveryConflict
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
void pgstat_report_wal(void)
PgStat_Shared_Reset_Target
PgStat_Counter tuples_inserted
PgStat_FunctionCounts * fs
PgStat_Counter f_numcalls
PgStat_Counter m_wal_sync_time
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
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
PgStat_MsgAnlAncestors msg_anl_ancestors
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_RecoveryPrefetchStats * pgstat_fetch_recoveryprefetch(void)
PgStat_Counter n_conflict_tablespace
PgStat_Counter m_spill_txns
PgStat_Counter wal_write_time
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
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
void pgstat_report_anl_ancestors(Oid relid)
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)
PgStat_RecoveryPrefetchStats m_stats
void pgstat_vacuum_stat(void)
PgStat_Counter m_wal_write_time
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
PgStat_Counter n_tuples_deleted
TimestampTz stat_reset_timestamp
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
PgStat_Counter pgStatActiveTime
struct PgStat_WalStats PgStat_WalStats
struct PgStat_TableXactStatus * upper
PgStat_Counter n_xact_rollback
PgStat_Counter m_wal_buffers_full
SessionEndType pgStatSessionEndCause
PgStat_Counter t_tuples_deleted
PgStat_Counter buf_written_clean
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
struct PgStat_MsgRecoveryPrefetch PgStat_MsgRecoveryPrefetch
PgStat_Counter m_idle_in_xact_time
PgStat_Counter m_wal_write
PgStat_Counter m_live_tuples
void pgstat_drop_database(Oid databaseid)
void pgstat_count_slru_truncate(int slru_idx)
struct PgStat_MsgResetsharedcounter PgStat_MsgResetsharedcounter
struct PgStat_FunctionCounts PgStat_FunctionCounts
#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)
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
struct PgStat_TableXactStatus PgStat_TableXactStatus
PGDLLIMPORT bool pgstat_track_counts
PgStat_Counter n_tuples_updated
PgStat_Counter pgStatTransactionIdleTime
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
void pgstat_report_replslot(const PgStat_ReplSlotStats *repSlotStat)
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
PgStat_Counter m_total_txns
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
PgStat_Counter m_total_bytes
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
struct PgStat_TableXactStatus * trans
struct PgStat_TableStatus PgStat_TableStatus
PgStat_MsgResetreplslotcounter msg_resetreplslotcounter
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)
PgStat_Counter changes_since_analyze_reported
void pgstat_count_heap_update(Relation rel, bool hot)
PgStat_BackendFunctionEntry * find_funcstat_entry(Oid func_id)
PgStat_Counter total_bytes
void pgstat_init_function_usage(struct FunctionCallInfoBaseData *fcinfo, PgStat_FunctionCallUsage *fcu)
PgStat_Counter m_session_time
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
PgStat_MsgArchiver msg_archiver
void pgstat_report_analyze(Relation rel, PgStat_Counter livetuples, PgStat_Counter deadtuples, bool resetcounter)
PgStat_MsgResetsinglecounter msg_resetsinglecounter
PgStat_Counter requested_checkpoints
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
bool pgstat_send_wal(bool force)
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
PgStat_MsgInquiry msg_inquiry
PgStat_MsgDropdb msg_dropdb
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
#define PGSTAT_NUM_ANCESTORENTRIES
PgStat_Counter blocks_written
PgStat_MsgTabpurge msg_tabpurge
#define PGSTAT_NUM_FUNCPURGE
PgStat_TableStatus * parent
PGDLLIMPORT int pgstat_track_functions
PgStat_Counter t_blocks_fetched
void PostPrepare_PgStat(void)
PgStat_MsgFuncstat msg_funcstat
void pgstat_send_recoveryprefetch(PgStat_RecoveryPrefetchStats *stats)
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