PGMon - databázová struktura
V tomto článku najdete stručný popis databázové struktury projektu PGMon - tabulkách, jejich struktuře, apod.
Databázová struktura je tvořena pouze čtyřmi tabulkami - Tables, Indexes, Databases a BgWriter, jejichž význam je celkem zřejmý již z jejich názvů. Podívejme se na jejich strukturu.
Tables
Do této tabulky jsou ukládány informace z tabulek pg_stat_all_tables, pg_statio_all_tables a pg_class, což jsou systémové katalogy, aktualizované interními procesy. Pro dostupnost některých informací musí být funkční "sběrač statistik" (statistics collector).
| název | typ | NULL | výchozí hodnota | poznámka |
|---|---|---|---|---|
| stat_time | timestamp | ne | now() | primary key |
| dbname | varchar(64) | ne | primary key | |
| schemaname | varchar(64) | ne | primary key | |
| tablename | varchar(64) | ne | primary key | |
| seq_scan | bigint | ano | ||
| seq_tup_read | bigint | ano | ||
| idx_scan | bigint | ano | ||
| idx_tup_fetch | bigint | ano | ||
| heap_blks_read | bigint | ano | ||
| heap_blks_hit | bigint | ano | ||
| idx_blks_read | bigint | ano | ||
| idx_blks_hit | bigint | ano | ||
| toast_blks_read | bigint | ano | ||
| toast_blks_hit | bigint | ano | ||
| tidx_blks_read | bigint | ano | ||
| tidx_blks_hit | bigint | ano | ||
| n_tup_ins | bigint | ano | ||
| n_tup_upd | bigint | ano | ||
| n_tup_del | bigint | ano | ||
| n_pages | integer | ano | ||
| n_tuples | integer | ano | ||
| last_vacuum | timestamp | ano | ||
| last_autovacuum | timestamp | ano | ||
| last_analyze | timestamp | ano | ||
| last_autoanalyze | timestamp | ano |
Obsahem tabulky jsou základní informace o tabulce (počet položek / stránek), informace o jejím využití (počet sekvenčních a index scanů, využití cache, počet načtených bloků, počet bloků načtených z cache, informace o využití TOAST, ...).
Tato tabulka také obsahuje o činnosti autovacuum / autoanalyze démona, tj. datum posledního automatickém nebo ručního spuštění VACUUM a ANALYZE nad tabulkou (a spolu s ní i všechny příslušné indexy).
Indexes
Do této tabulky jsou ukládány informace z tabulek pg_stat_all_indexes, pg_statio_all_indexes a pg_class, což jsou systémové katalogy, aktualizované interními procesy. Pro dostupnost některých informací musí být funkční "sběrač statistik" (statistics collector).
| název | typ | NULL | výchozí hodnota | poznámka |
|---|---|---|---|---|
| stat_time | timestamp | ne | now() | primary key |
| dbname | varchar(64) | ne | primary key | |
| schemaname | varchar(64) | ne | primary key | |
| tablename | varchar(64) | ne | primary key | |
| indexname | varchar(64) | ne | primary key | |
| idx_scan | bigint | ano | ||
| idx_tup_read | bigint | ano | ||
| idx_tup_fetch | bigint | ano | ||
| idx_blks_read | bigint | ano | ||
| idx_blks_hit | bigint | ano | ||
| n_pages | integer | ano | ||
| n_tuples | integer | ano | ||
| n_table_pages | integer | ano | ||
| n_table_tuples | integer | ano |
Obsahem tabulky jsou základní informace o indexu (počet položek / stránek), informace o využití indexu (počet index scanů, využití cache, počet načtených bloků, počet bloků načtených z cache, ...).
Tato tabulka na rozdíl od tabulky Tables neobsahuje informace o činnosti autovacuum / autoanalyze démona, protože vakuována je vždy celá tabulka (a spolu s ní i všechny příslušné indexy).
databases
Tato tabulka je pouze "otiskem" systémového katalogu pg_stat_database. Obsahuje informace o každé databázi v systému - počet commitů, rollbacků, načtených bloků a účinnosti cache.
| název | typ | NULL | výchozí hodnota | poznámka |
|---|---|---|---|---|
| stat_time | timestamp | no | now() | primary key |
| dbname | varchar(64) | no | 0 | |
| backends | integer | no | 0 | |
| n_commits | bigint | no | 0 | |
| n_rollbacks | bigint | no | 0 | |
| blks_read | bigint | no | 0 | |
| blks_hit | bigin | no | 0 |
BgWriter
Tato tabulka obsahuje statistické informace o celém clusteru, resp. o procesech a součástech které jsou společné pro celý cluster (bgwriter, shared buffer pool, etc.).
| název | typ | NULL | výchozí hodnota | poznámka |
|---|---|---|---|---|
| stat_time | timestamp | no | now() | primary key |
| hostname | varchar(64) | no | primary key | |
| checkpoints_timed | bigint | no | ||
| checkpoints_req | bigint | no | ||
| buffers_checkpoint | bigint | no | ||
| buffers_clean | bigint | no | ||
| maxwritten_clean | bigint | no | ||
| buffers_backend | bigint | no | ||
| buffers_alloc | bigint | no |
Tabulka zahrnuje informace o statistiky checkpointů, počet spuštění a přerušení "cleaning scanů", statistiky shared buffer poolu, apod.
Poznámka: Tato tabulka (resp. systémový katalog pg_stat_bgwriter ze kterého jsou načítána data) není dostupná pro verze PosgreSQL před 8.3.




