diff options
| author | Magnus Hagander | 2007-03-30 18:34:56 +0000 |
|---|---|---|
| committer | Magnus Hagander | 2007-03-30 18:34:56 +0000 |
| commit | 335feca441b338f796e205f0e227b2f3a43f130e (patch) | |
| tree | 9b11d242f2d60e4e38c87cb74946f04889de49bf /src/include | |
| parent | f9ce21f94cd90ffa5e6c63c91e8b05aa0b6d2b25 (diff) | |
Add some instrumentation to the bgwriter, through the stats collector.
New view pg_stat_bgwriter, and the functions required to build it.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_proc.h | 16 | ||||
| -rw-r--r-- | src/include/pgstat.h | 41 |
3 files changed, 56 insertions, 5 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 270687b153..aa0e29a216 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.396 2007/03/27 23:21:11 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.397 2007/03/30 18:34:56 mha Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200703271 +#define CATALOG_VERSION_NO 200703301 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 44e585e9c4..713d76fbfa 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.451 2007/03/27 23:21:11 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.452 2007/03/30 18:34:56 mha Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -2987,6 +2987,20 @@ DATA(insert OID = 2761 ( pg_stat_get_db_tuples_updated PGNSP PGUID 12 1 0 f f t DESCR("Statistics: Tuples updated in database"); DATA(insert OID = 2762 ( pg_stat_get_db_tuples_deleted PGNSP PGUID 12 1 0 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_db_tuples_deleted - _null_ )); DESCR("Statistics: Tuples deleted in database"); +DATA(insert OID = 2769 ( pg_stat_get_bgwriter_timed_checkpoints PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_timed_checkpoints - _null_ )); +DESCR("Statistics: Number of timed checkpoints started by the bgwriter"); +DATA(insert OID = 2770 ( pg_stat_get_bgwriter_requested_checkpoints PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_requested_checkpoints - _null_ )); +DESCR("Statistics: Number of backend requested checkpoints started by the bgwriter"); +DATA(insert OID = 2771 ( pg_stat_get_bgwriter_buf_written_checkpoints PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_buf_written_checkpoints - _null_ )); +DESCR("Statistics: Number of buffers written by the bgwriter during checkpoints"); +DATA(insert OID = 2772 ( pg_stat_get_bgwriter_buf_written_lru PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_buf_written_lru - _null_ )); +DESCR("Statistics: Number of buffers written by the bgwriter during LRU scans"); +DATA(insert OID = 2773 ( pg_stat_get_bgwriter_buf_written_all PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_buf_written_all - _null_ )); +DESCR("Statistics: Number of buffers written by the bgwriter during all-buffer scans"); +DATA(insert OID = 2774 ( pg_stat_get_bgwriter_maxwritten_lru PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_maxwritten_lru - _null_ )); +DESCR("Statistics: Number of times the bgwriter stopped processing when it had written too many buffers during LRU scans"); +DATA(insert OID = 2775 ( pg_stat_get_bgwriter_maxwritten_all PGNSP PGUID 12 1 0 f f t f s 0 20 "" _null_ _null_ _null_ pg_stat_get_bgwriter_maxwritten_all - _null_ )); +DESCR("Statistics: Number of times the bgwriter stopped processing when it had written too many buffers during all-buffer scans"); DATA(insert OID = 2230 ( pg_stat_clear_snapshot PGNSP PGUID 12 1 0 f f f f v 0 2278 "" _null_ _null_ _null_ pg_stat_clear_snapshot - _null_ )); DESCR("Statistics: Discard current transaction's statistics snapshot"); DATA(insert OID = 2274 ( pg_stat_reset PGNSP PGUID 12 1 0 f f f f v 0 2278 "" _null_ _null_ _null_ pg_stat_reset - _null_ )); diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 8e08db4c17..3cfcea7e4b 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -5,7 +5,7 @@ * * Copyright (c) 2001-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.56 2007/03/22 19:53:31 momjian Exp $ + * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.57 2007/03/30 18:34:55 mha Exp $ * ---------- */ #ifndef PGSTAT_H @@ -30,7 +30,8 @@ typedef enum StatMsgType PGSTAT_MTYPE_RESETCOUNTER, PGSTAT_MTYPE_AUTOVAC_START, PGSTAT_MTYPE_VACUUM, - PGSTAT_MTYPE_ANALYZE + PGSTAT_MTYPE_ANALYZE, + PGSTAT_MTYPE_BGWRITER } StatMsgType; /* ---------- @@ -213,6 +214,24 @@ typedef struct PgStat_MsgAnalyze /* ---------- + * PgStat_MsgBgWriter Sent by the bgwriter to update statistics. + * ---------- + */ +typedef struct PgStat_MsgBgWriter +{ + PgStat_MsgHdr m_hdr; + + PgStat_Counter m_timed_checkpoints; + PgStat_Counter m_requested_checkpoints; + PgStat_Counter m_buf_written_checkpoints; + PgStat_Counter m_buf_written_lru; + PgStat_Counter m_buf_written_all; + PgStat_Counter m_maxwritten_lru; + PgStat_Counter m_maxwritten_all; +} PgStat_MsgBgWriter; + + +/* ---------- * PgStat_Msg Union over all possible messages. * ---------- */ @@ -227,6 +246,7 @@ typedef union PgStat_Msg PgStat_MsgAutovacStart msg_autovacuum; PgStat_MsgVacuum msg_vacuum; PgStat_MsgAnalyze msg_analyze; + PgStat_MsgBgWriter msg_bgwriter; } PgStat_Msg; @@ -297,6 +317,21 @@ typedef struct PgStat_StatTabEntry } PgStat_StatTabEntry; +/* + * Global statistics kept in the stats collector + */ +typedef struct PgStat_GlobalStats +{ + PgStat_Counter timed_checkpoints; + PgStat_Counter requested_checkpoints; + PgStat_Counter buf_written_checkpoints; + PgStat_Counter buf_written_lru; + PgStat_Counter buf_written_all; + PgStat_Counter maxwritten_lru; + PgStat_Counter maxwritten_all; +} PgStat_GlobalStats; + + /* ---------- * Shared-memory data structures * ---------- @@ -478,6 +513,7 @@ extern void pgstat_initstats(PgStat_Info *stats, Relation rel); extern void pgstat_count_xact_commit(void); extern void pgstat_count_xact_rollback(void); +extern void pgstat_send_bgwriter(void); /* ---------- * Support functions for the SQL-callable functions to @@ -488,5 +524,6 @@ extern PgStat_StatDBEntry *pgstat_fetch_stat_dbentry(Oid dbid); extern PgStat_StatTabEntry *pgstat_fetch_stat_tabentry(Oid relid); extern PgBackendStatus *pgstat_fetch_stat_beentry(int beid); extern int pgstat_fetch_stat_numbackends(void); +extern PgStat_GlobalStats *pgstat_fetch_global(void); #endif /* PGSTAT_H */ |
