codekingpro/portable-devtools
116k
1/* ----------2 * pgstat.h3 *4 * Definitions for the PostgreSQL cumulative statistics system.5 *6 * Copyright (c) 2001-2023, PostgreSQL Global Development Group7 *8 * src/include/pgstat.h9 * ----------10 */11#ifndef PGSTAT_H12#define PGSTAT_H13 14#include "datatype/timestamp.h"15#include "portability/instr_time.h"16#include "postmaster/pgarch.h" /* for MAX_XFN_CHARS */17#include "utils/backend_progress.h" /* for backward compatibility */18#include "utils/backend_status.h" /* for backward compatibility */19#include "utils/relcache.h"20#include "utils/wait_event.h" /* for backward compatibility */21 22 23/* ----------24 * Paths for the statistics files (relative to installation's $PGDATA).25 * ----------26 */27#define PGSTAT_STAT_PERMANENT_DIRECTORY "pg_stat"28#define PGSTAT_STAT_PERMANENT_FILENAME "pg_stat/pgstat.stat"29#define PGSTAT_STAT_PERMANENT_TMPFILE "pg_stat/pgstat.tmp"30 31/* Default directory to store temporary statistics data in */32#define PG_STAT_TMP_DIR "pg_stat_tmp"33 34/* The types of statistics entries */35typedef enum PgStat_Kind36{37 /* use 0 for INVALID, to catch zero-initialized data */38 PGSTAT_KIND_INVALID = 0,39 40 /* stats for variable-numbered objects */41 PGSTAT_KIND_DATABASE, /* database-wide statistics */42 PGSTAT_KIND_RELATION, /* per-table statistics */43 PGSTAT_KIND_FUNCTION, /* per-function statistics */44 PGSTAT_KIND_REPLSLOT, /* per-slot statistics */45 PGSTAT_KIND_SUBSCRIPTION, /* per-subscription statistics */46 47 /* stats for fixed-numbered objects */48 PGSTAT_KIND_ARCHIVER,49 PGSTAT_KIND_BGWRITER,50 PGSTAT_KIND_CHECKPOINTER,51 PGSTAT_KIND_IO,52 PGSTAT_KIND_SLRU,53 PGSTAT_KIND_WAL,54} PgStat_Kind;55 56#define PGSTAT_KIND_FIRST_VALID PGSTAT_KIND_DATABASE57#define PGSTAT_KIND_LAST PGSTAT_KIND_WAL58#define PGSTAT_NUM_KINDS (PGSTAT_KIND_LAST + 1)59 60/* Values for track_functions GUC variable --- order is significant! */61typedef enum TrackFunctionsLevel62{63 TRACK_FUNC_OFF,64 TRACK_FUNC_PL,65 TRACK_FUNC_ALL66} TrackFunctionsLevel;67 68typedef enum PgStat_FetchConsistency69{70 PGSTAT_FETCH_CONSISTENCY_NONE,71 PGSTAT_FETCH_CONSISTENCY_CACHE,72 PGSTAT_FETCH_CONSISTENCY_SNAPSHOT,73} PgStat_FetchConsistency;74 75/* Values to track the cause of session termination */76typedef enum SessionEndType77{78 DISCONNECT_NOT_YET, /* still active */79 DISCONNECT_NORMAL,80 DISCONNECT_CLIENT_EOF,81 DISCONNECT_FATAL,82 DISCONNECT_KILLED83} SessionEndType;84 85/* ----------86 * The data type used for counters.87 * ----------88 */89typedef int64 PgStat_Counter;90 91 92/* ------------------------------------------------------------93 * Structures kept in backend local memory while accumulating counts94 * ------------------------------------------------------------95 */96 97/* ----------98 * PgStat_FunctionCounts The actual per-function counts kept by a backend99 *100 * This struct should contain only actual event counters, because we memcmp101 * it against zeroes to detect whether there are any pending stats.102 *103 * Note that the time counters are in instr_time format here. We convert to104 * microseconds in PgStat_Counter format when flushing out pending statistics.105 * ----------106 */107typedef struct PgStat_FunctionCounts108{109 PgStat_Counter numcalls;110 instr_time total_time;111 instr_time self_time;112} PgStat_FunctionCounts;113 114/*115 * Working state needed to accumulate per-function-call timing statistics.116 */117typedef struct PgStat_FunctionCallUsage118{119 /* Link to function's hashtable entry (must still be there at exit!) */120 /* NULL means we are not tracking the current function call */121 PgStat_FunctionCounts *fs;122 /* Total time previously charged to function, as of function start */123 instr_time save_f_total_time;124 /* Backend-wide total time as of function start */125 instr_time save_total;126 /* system clock as of function start */127 instr_time start;128} PgStat_FunctionCallUsage;129 130/* ----------131 * PgStat_BackendSubEntry Non-flushed subscription stats.132 * ----------133 */134typedef struct PgStat_BackendSubEntry135{136 PgStat_Counter apply_error_count;137 PgStat_Counter sync_error_count;138} PgStat_BackendSubEntry;139 140/* ----------141 * PgStat_TableCounts The actual per-table counts kept by a backend142 *143 * This struct should contain only actual event counters, because we memcmp144 * it against zeroes to detect whether there are any stats updates to apply.145 * It is a component of PgStat_TableStatus (within-backend state).146 *147 * Note: for a table, tuples_returned is the number of tuples successfully148 * fetched by heap_getnext, while tuples_fetched is the number of tuples149 * successfully fetched by heap_fetch under the control of bitmap indexscans.150 * For an index, tuples_returned is the number of index entries returned by151 * the index AM, while tuples_fetched is the number of tuples successfully152 * fetched by heap_fetch under the control of simple indexscans for this index.153 *154 * tuples_inserted/updated/deleted/hot_updated/newpage_updated count attempted155 * actions, regardless of whether the transaction committed. delta_live_tuples,156 * delta_dead_tuples, and changed_tuples are set depending on commit or abort.157 * Note that delta_live_tuples and delta_dead_tuples can be negative!158 * ----------159 */160typedef struct PgStat_TableCounts161{162 PgStat_Counter numscans;163 164 PgStat_Counter tuples_returned;165 PgStat_Counter tuples_fetched;166 167 PgStat_Counter tuples_inserted;168 PgStat_Counter tuples_updated;169 PgStat_Counter tuples_deleted;170 PgStat_Counter tuples_hot_updated;171 PgStat_Counter tuples_newpage_updated;172 bool truncdropped;173 174 PgStat_Counter delta_live_tuples;175 PgStat_Counter delta_dead_tuples;176 PgStat_Counter changed_tuples;177 178 PgStat_Counter blocks_fetched;179 PgStat_Counter blocks_hit;180} PgStat_TableCounts;181 182/* ----------183 * PgStat_TableStatus Per-table status within a backend184 *185 * Many of the event counters are nontransactional, ie, we count events186 * in committed and aborted transactions alike. For these, we just count187 * directly in the PgStat_TableStatus. However, delta_live_tuples,188 * delta_dead_tuples, and changed_tuples must be derived from event counts189 * with awareness of whether the transaction or subtransaction committed or190 * aborted. Hence, we also keep a stack of per-(sub)transaction status191 * records for every table modified in the current transaction. At commit192 * or abort, we propagate tuples_inserted/updated/deleted up to the193 * parent subtransaction level, or out to the parent PgStat_TableStatus,194 * as appropriate.195 * ----------196 */197typedef struct PgStat_TableStatus198{199 Oid id; /* table's OID */200 bool shared; /* is it a shared catalog? */201 struct PgStat_TableXactStatus *trans; /* lowest subxact's counts */202 PgStat_TableCounts counts; /* event counts to be sent */203 Relation relation; /* rel that is using this entry */204} PgStat_TableStatus;205 206/* ----------207 * PgStat_TableXactStatus Per-table, per-subtransaction status208 * ----------209 */210typedef struct PgStat_TableXactStatus211{212 PgStat_Counter tuples_inserted; /* tuples inserted in (sub)xact */213 PgStat_Counter tuples_updated; /* tuples updated in (sub)xact */214 PgStat_Counter tuples_deleted; /* tuples deleted in (sub)xact */215 bool truncdropped; /* relation truncated/dropped in this216 * (sub)xact */217 /* tuples i/u/d prior to truncate/drop */218 PgStat_Counter inserted_pre_truncdrop;219 PgStat_Counter updated_pre_truncdrop;220 PgStat_Counter deleted_pre_truncdrop;221 int nest_level; /* subtransaction nest level */222 /* links to other structs for same relation: */223 struct PgStat_TableXactStatus *upper; /* next higher subxact if any */224 PgStat_TableStatus *parent; /* per-table status */225 /* structs of same subxact level are linked here: */226 struct PgStat_TableXactStatus *next; /* next of same subxact */227} PgStat_TableXactStatus;228 229 230/* ------------------------------------------------------------231 * Data structures on disk and in shared memory follow232 *233 * PGSTAT_FILE_FORMAT_ID should be changed whenever any of these234 * data structures change.235 * ------------------------------------------------------------236 */237 238#define PGSTAT_FILE_FORMAT_ID 0x01A5BCAC239 240typedef struct PgStat_ArchiverStats241{242 PgStat_Counter archived_count; /* archival successes */243 char last_archived_wal[MAX_XFN_CHARS + 1]; /* last WAL file244 * archived */245 TimestampTz last_archived_timestamp; /* last archival success time */246 PgStat_Counter failed_count; /* failed archival attempts */247 char last_failed_wal[MAX_XFN_CHARS + 1]; /* WAL file involved in248 * last failure */249 TimestampTz last_failed_timestamp; /* last archival failure time */250 TimestampTz stat_reset_timestamp;251} PgStat_ArchiverStats;252 253typedef struct PgStat_BgWriterStats254{255 PgStat_Counter buf_written_clean;256 PgStat_Counter maxwritten_clean;257 PgStat_Counter buf_alloc;258 TimestampTz stat_reset_timestamp;259} PgStat_BgWriterStats;260 261typedef struct PgStat_CheckpointerStats262{263 PgStat_Counter timed_checkpoints;264 PgStat_Counter requested_checkpoints;265 PgStat_Counter checkpoint_write_time; /* times in milliseconds */266 PgStat_Counter checkpoint_sync_time;267 PgStat_Counter buf_written_checkpoints;268 PgStat_Counter buf_written_backend;269 PgStat_Counter buf_fsync_backend;270} PgStat_CheckpointerStats;271 272 273/*274 * Types related to counting IO operations275 */276typedef enum IOObject277{278 IOOBJECT_RELATION,279 IOOBJECT_TEMP_RELATION,280} IOObject;281 282#define IOOBJECT_NUM_TYPES (IOOBJECT_TEMP_RELATION + 1)283 284typedef enum IOContext285{286 IOCONTEXT_BULKREAD,287 IOCONTEXT_BULKWRITE,288 IOCONTEXT_NORMAL,289 IOCONTEXT_VACUUM,290} IOContext;291 292#define IOCONTEXT_NUM_TYPES (IOCONTEXT_VACUUM + 1)293 294typedef enum IOOp295{296 IOOP_EVICT,297 IOOP_EXTEND,298 IOOP_FSYNC,299 IOOP_HIT,300 IOOP_READ,301 IOOP_REUSE,302 IOOP_WRITE,303 IOOP_WRITEBACK,304} IOOp;305 306#define IOOP_NUM_TYPES (IOOP_WRITEBACK + 1)307 308typedef struct PgStat_BktypeIO309{310 PgStat_Counter counts[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES];311 PgStat_Counter times[IOOBJECT_NUM_TYPES][IOCONTEXT_NUM_TYPES][IOOP_NUM_TYPES];312} PgStat_BktypeIO;313 314typedef struct PgStat_IO315{316 TimestampTz stat_reset_timestamp;317 PgStat_BktypeIO stats[BACKEND_NUM_TYPES];318} PgStat_IO;319 320 321typedef struct PgStat_StatDBEntry322{323 PgStat_Counter xact_commit;324 PgStat_Counter xact_rollback;325 PgStat_Counter blocks_fetched;326 PgStat_Counter blocks_hit;327 PgStat_Counter tuples_returned;328 PgStat_Counter tuples_fetched;329 PgStat_Counter tuples_inserted;330 PgStat_Counter tuples_updated;331 PgStat_Counter tuples_deleted;332 TimestampTz last_autovac_time;333 PgStat_Counter conflict_tablespace;334 PgStat_Counter conflict_lock;335 PgStat_Counter conflict_snapshot;336 PgStat_Counter conflict_logicalslot;337 PgStat_Counter conflict_bufferpin;338 PgStat_Counter conflict_startup_deadlock;339 PgStat_Counter temp_files;340 PgStat_Counter temp_bytes;341 PgStat_Counter deadlocks;342 PgStat_Counter checksum_failures;343 TimestampTz last_checksum_failure;344 PgStat_Counter blk_read_time; /* times in microseconds */345 PgStat_Counter blk_write_time;346 PgStat_Counter sessions;347 PgStat_Counter session_time;348 PgStat_Counter active_time;349 PgStat_Counter idle_in_transaction_time;350 PgStat_Counter sessions_abandoned;351 PgStat_Counter sessions_fatal;352 PgStat_Counter sessions_killed;353 354 TimestampTz stat_reset_timestamp;355} PgStat_StatDBEntry;356 357typedef struct PgStat_StatFuncEntry358{359 PgStat_Counter numcalls;360 361 PgStat_Counter total_time; /* times in microseconds */362 PgStat_Counter self_time;363} PgStat_StatFuncEntry;364 365typedef struct PgStat_StatReplSlotEntry366{367 PgStat_Counter spill_txns;368 PgStat_Counter spill_count;369 PgStat_Counter spill_bytes;370 PgStat_Counter stream_txns;371 PgStat_Counter stream_count;372 PgStat_Counter stream_bytes;373 PgStat_Counter total_txns;374 PgStat_Counter total_bytes;375 TimestampTz stat_reset_timestamp;376} PgStat_StatReplSlotEntry;377 378typedef struct PgStat_SLRUStats379{380 PgStat_Counter blocks_zeroed;381 PgStat_Counter blocks_hit;382 PgStat_Counter blocks_read;383 PgStat_Counter blocks_written;384 PgStat_Counter blocks_exists;385 PgStat_Counter flush;386 PgStat_Counter truncate;387 TimestampTz stat_reset_timestamp;388} PgStat_SLRUStats;389 390typedef struct PgStat_StatSubEntry391{392 PgStat_Counter apply_error_count;393 PgStat_Counter sync_error_count;394 TimestampTz stat_reset_timestamp;395} PgStat_StatSubEntry;396 397typedef struct PgStat_StatTabEntry398{399 PgStat_Counter numscans;400 TimestampTz lastscan;401 402 PgStat_Counter tuples_returned;403 PgStat_Counter tuples_fetched;404 405 PgStat_Counter tuples_inserted;406 PgStat_Counter tuples_updated;407 PgStat_Counter tuples_deleted;408 PgStat_Counter tuples_hot_updated;409 PgStat_Counter tuples_newpage_updated;410 411 PgStat_Counter live_tuples;412 PgStat_Counter dead_tuples;413 PgStat_Counter mod_since_analyze;414 PgStat_Counter ins_since_vacuum;415 416 PgStat_Counter blocks_fetched;417 PgStat_Counter blocks_hit;418 419 TimestampTz last_vacuum_time; /* user initiated vacuum */420 PgStat_Counter vacuum_count;421 TimestampTz last_autovacuum_time; /* autovacuum initiated */422 PgStat_Counter autovacuum_count;423 TimestampTz last_analyze_time; /* user initiated */424 PgStat_Counter analyze_count;425 TimestampTz last_autoanalyze_time; /* autovacuum initiated */426 PgStat_Counter autoanalyze_count;427} PgStat_StatTabEntry;428 429typedef struct PgStat_WalStats430{431 PgStat_Counter wal_records;432 PgStat_Counter wal_fpi;433 uint64 wal_bytes;434 PgStat_Counter wal_buffers_full;435 PgStat_Counter wal_write;436 PgStat_Counter wal_sync;437 PgStat_Counter wal_write_time;438 PgStat_Counter wal_sync_time;439 TimestampTz stat_reset_timestamp;440} PgStat_WalStats;441 442/*443 * This struct stores wal-related durations as instr_time, which makes it444 * cheaper and easier to accumulate them, by not requiring type445 * conversions. During stats flush instr_time will be converted into446 * microseconds.447 */448typedef struct PgStat_PendingWalStats449{450 PgStat_Counter wal_buffers_full;451 PgStat_Counter wal_write;452 PgStat_Counter wal_sync;453 instr_time wal_write_time;454 instr_time wal_sync_time;455} PgStat_PendingWalStats;456 457 458/*459 * Functions in pgstat.c460 */461 462/* functions called from postmaster */463extern Size StatsShmemSize(void);464extern void StatsShmemInit(void);465 466/* Functions called during server startup / shutdown */467extern void pgstat_restore_stats(void);468extern void pgstat_discard_stats(void);469extern void pgstat_before_server_shutdown(int code, Datum arg);470 471/* Functions for backend initialization */472extern void pgstat_initialize(void);473 474/* Functions called from backends */475extern long pgstat_report_stat(bool force);476extern void pgstat_force_next_flush(void);477 478extern void pgstat_reset_counters(void);479extern void pgstat_reset(PgStat_Kind kind, Oid dboid, Oid objoid);480extern void pgstat_reset_of_kind(PgStat_Kind kind);481 482/* stats accessors */483extern void pgstat_clear_snapshot(void);484extern TimestampTz pgstat_get_stat_snapshot_timestamp(bool *have_snapshot);485 486/* helpers */487extern PgStat_Kind pgstat_get_kind_from_str(char *kind_str);488extern bool pgstat_have_entry(PgStat_Kind kind, Oid dboid, Oid objoid);489 490 491/*492 * Functions in pgstat_archiver.c493 */494 495extern void pgstat_report_archiver(const char *xlog, bool failed);496extern PgStat_ArchiverStats *pgstat_fetch_stat_archiver(void);497 498 499/*500 * Functions in pgstat_bgwriter.c501 */502 503extern void pgstat_report_bgwriter(void);504extern PgStat_BgWriterStats *pgstat_fetch_stat_bgwriter(void);505 506 507/*508 * Functions in pgstat_checkpointer.c509 */510 511extern void pgstat_report_checkpointer(void);512extern PgStat_CheckpointerStats *pgstat_fetch_stat_checkpointer(void);513 514 515/*516 * Functions in pgstat_io.c517 */518 519extern bool pgstat_bktype_io_stats_valid(PgStat_BktypeIO *backend_io,520 BackendType bktype);521extern void pgstat_count_io_op(IOObject io_object, IOContext io_context, IOOp io_op);522extern void pgstat_count_io_op_n(IOObject io_object, IOContext io_context, IOOp io_op, uint32 cnt);523extern instr_time pgstat_prepare_io_time(void);524extern void pgstat_count_io_op_time(IOObject io_object, IOContext io_context,525 IOOp io_op, instr_time start_time, uint32 cnt);526 527extern PgStat_IO *pgstat_fetch_stat_io(void);528extern const char *pgstat_get_io_context_name(IOContext io_context);529extern const char *pgstat_get_io_object_name(IOObject io_object);530 531extern bool pgstat_tracks_io_bktype(BackendType bktype);532extern bool pgstat_tracks_io_object(BackendType bktype,533 IOObject io_object, IOContext io_context);534extern bool pgstat_tracks_io_op(BackendType bktype, IOObject io_object,535 IOContext io_context, IOOp io_op);536 537 538/*539 * Functions in pgstat_database.c540 */541 542extern void pgstat_drop_database(Oid databaseid);543extern void pgstat_report_autovac(Oid dboid);544extern void pgstat_report_recovery_conflict(int reason);545extern void pgstat_report_deadlock(void);546extern void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount);547extern void pgstat_report_checksum_failure(void);548extern void pgstat_report_connect(Oid dboid);549 550#define pgstat_count_buffer_read_time(n) \551 (pgStatBlockReadTime += (n))552#define pgstat_count_buffer_write_time(n) \553 (pgStatBlockWriteTime += (n))554#define pgstat_count_conn_active_time(n) \555 (pgStatActiveTime += (n))556#define pgstat_count_conn_txn_idle_time(n) \557 (pgStatTransactionIdleTime += (n))558 559extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dboid);560 561 562/*563 * Functions in pgstat_function.c564 */565 566extern void pgstat_create_function(Oid proid);567extern void pgstat_drop_function(Oid proid);568 569struct FunctionCallInfoBaseData;570extern void pgstat_init_function_usage(struct FunctionCallInfoBaseData *fcinfo,571 PgStat_FunctionCallUsage *fcu);572extern void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu,573 bool finalize);574 575extern PgStat_StatFuncEntry *pgstat_fetch_stat_funcentry(Oid func_id);576extern PgStat_FunctionCounts *find_funcstat_entry(Oid func_id);577 578 579/*580 * Functions in pgstat_relation.c581 */582 583extern void pgstat_create_relation(Relation rel);584extern void pgstat_drop_relation(Relation rel);585extern void pgstat_copy_relation_stats(Relation dst, Relation src);586 587extern void pgstat_init_relation(Relation rel);588extern void pgstat_assoc_relation(Relation rel);589extern void pgstat_unlink_relation(Relation rel);590 591extern void pgstat_report_vacuum(Oid tableoid, bool shared,592 PgStat_Counter livetuples, PgStat_Counter deadtuples);593extern void pgstat_report_analyze(Relation rel,594 PgStat_Counter livetuples, PgStat_Counter deadtuples,595 bool resetcounter);596 597/*598 * If stats are enabled, but pending data hasn't been prepared yet, call599 * pgstat_assoc_relation() to do so. See its comment for why this is done600 * separately from pgstat_init_relation().601 */602#define pgstat_should_count_relation(rel) \603 (likely((rel)->pgstat_info != NULL) ? true : \604 ((rel)->pgstat_enabled ? pgstat_assoc_relation(rel), true : false))605 606/* nontransactional event counts are simple enough to inline */607 608#define pgstat_count_heap_scan(rel) \609 do { \610 if (pgstat_should_count_relation(rel)) \611 (rel)->pgstat_info->counts.numscans++; \612 } while (0)613#define pgstat_count_heap_getnext(rel) \614 do { \615 if (pgstat_should_count_relation(rel)) \616 (rel)->pgstat_info->counts.tuples_returned++; \617 } while (0)618#define pgstat_count_heap_fetch(rel) \619 do { \620 if (pgstat_should_count_relation(rel)) \621 (rel)->pgstat_info->counts.tuples_fetched++; \622 } while (0)623#define pgstat_count_index_scan(rel) \624 do { \625 if (pgstat_should_count_relation(rel)) \626 (rel)->pgstat_info->counts.numscans++; \627 } while (0)628#define pgstat_count_index_tuples(rel, n) \629 do { \630 if (pgstat_should_count_relation(rel)) \631 (rel)->pgstat_info->counts.tuples_returned += (n); \632 } while (0)633#define pgstat_count_buffer_read(rel) \634 do { \635 if (pgstat_should_count_relation(rel)) \636 (rel)->pgstat_info->counts.blocks_fetched++; \637 } while (0)638#define pgstat_count_buffer_hit(rel) \639 do { \640 if (pgstat_should_count_relation(rel)) \641 (rel)->pgstat_info->counts.blocks_hit++; \642 } while (0)643 644extern void pgstat_count_heap_insert(Relation rel, PgStat_Counter n);645extern void pgstat_count_heap_update(Relation rel, bool hot, bool newpage);646extern void pgstat_count_heap_delete(Relation rel);647extern void pgstat_count_truncate(Relation rel);648extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);649 650extern void pgstat_twophase_postcommit(TransactionId xid, uint16 info,651 void *recdata, uint32 len);652extern void pgstat_twophase_postabort(TransactionId xid, uint16 info,653 void *recdata, uint32 len);654 655extern PgStat_StatTabEntry *pgstat_fetch_stat_tabentry(Oid relid);656extern PgStat_StatTabEntry *pgstat_fetch_stat_tabentry_ext(bool shared,657 Oid reloid);658extern PgStat_TableStatus *find_tabstat_entry(Oid rel_id);659 660 661/*662 * Functions in pgstat_replslot.c663 */664 665extern void pgstat_reset_replslot(const char *name);666struct ReplicationSlot;667extern void pgstat_report_replslot(struct ReplicationSlot *slot, const PgStat_StatReplSlotEntry *repSlotStat);668extern void pgstat_create_replslot(struct ReplicationSlot *slot);669extern void pgstat_acquire_replslot(struct ReplicationSlot *slot);670extern void pgstat_drop_replslot(struct ReplicationSlot *slot);671extern PgStat_StatReplSlotEntry *pgstat_fetch_replslot(NameData slotname);672 673 674/*675 * Functions in pgstat_slru.c676 */677 678extern void pgstat_reset_slru(const char *);679extern void pgstat_count_slru_page_zeroed(int slru_idx);680extern void pgstat_count_slru_page_hit(int slru_idx);681extern void pgstat_count_slru_page_read(int slru_idx);682extern void pgstat_count_slru_page_written(int slru_idx);683extern void pgstat_count_slru_page_exists(int slru_idx);684extern void pgstat_count_slru_flush(int slru_idx);685extern void pgstat_count_slru_truncate(int slru_idx);686extern const char *pgstat_get_slru_name(int slru_idx);687extern int pgstat_get_slru_index(const char *name);688extern PgStat_SLRUStats *pgstat_fetch_slru(void);689 690 691/*692 * Functions in pgstat_subscription.c693 */694 695extern void pgstat_report_subscription_error(Oid subid, bool is_apply_error);696extern void pgstat_create_subscription(Oid subid);697extern void pgstat_drop_subscription(Oid subid);698extern PgStat_StatSubEntry *pgstat_fetch_stat_subscription(Oid subid);699 700 701/*702 * Functions in pgstat_xact.c703 */704 705extern void AtEOXact_PgStat(bool isCommit, bool parallel);706extern void AtEOSubXact_PgStat(bool isCommit, int nestDepth);707extern void AtPrepare_PgStat(void);708extern void PostPrepare_PgStat(void);709struct xl_xact_stats_item;710extern int pgstat_get_transactional_drops(bool isCommit, struct xl_xact_stats_item **items);711extern void pgstat_execute_transactional_drops(int ndrops, struct xl_xact_stats_item *items, bool is_redo);712 713 714/*715 * Functions in pgstat_wal.c716 */717 718extern void pgstat_report_wal(bool force);719extern PgStat_WalStats *pgstat_fetch_stat_wal(void);720 721 722/*723 * Variables in pgstat.c724 */725 726/* GUC parameters */727extern PGDLLIMPORT bool pgstat_track_counts;728extern PGDLLIMPORT int pgstat_track_functions;729extern PGDLLIMPORT int pgstat_fetch_consistency;730 731 732/*733 * Variables in pgstat_bgwriter.c734 */735 736/* updated directly by bgwriter and bufmgr */737extern PGDLLIMPORT PgStat_BgWriterStats PendingBgWriterStats;738 739 740/*741 * Variables in pgstat_checkpointer.c742 */743 744/*745 * Checkpointer statistics counters are updated directly by checkpointer and746 * bufmgr.747 */748extern PGDLLIMPORT PgStat_CheckpointerStats PendingCheckpointerStats;749 750 751/*752 * Variables in pgstat_database.c753 */754 755/* Updated by pgstat_count_buffer_*_time macros */756extern PGDLLIMPORT PgStat_Counter pgStatBlockReadTime;757extern PGDLLIMPORT PgStat_Counter pgStatBlockWriteTime;758 759/*760 * Updated by pgstat_count_conn_*_time macros, called by761 * pgstat_report_activity().762 */763extern PGDLLIMPORT PgStat_Counter pgStatActiveTime;764extern PGDLLIMPORT PgStat_Counter pgStatTransactionIdleTime;765 766/* updated by the traffic cop and in errfinish() */767extern PGDLLIMPORT SessionEndType pgStatSessionEndCause;768 769 770/*771 * Variables in pgstat_wal.c772 */773 774/* updated directly by backends and background processes */775extern PGDLLIMPORT PgStat_PendingWalStats PendingWalStats;776 777 778#endif /* PGSTAT_H */779 