| 65 | |
| 66 | |
| 67 | == Sprawdzenie "poziomu zaśmiecenia" tabel w bazie == |
| 68 | |
| 69 | {{{ |
| 70 | SELECT psut.relname, |
| 71 | to_char(psut.last_vacuum, 'YYYY-MM-DD HH24:MI') as last_vacuum, |
| 72 | to_char(psut.last_autovacuum, 'YYYY-MM-DD HH24:MI') as last_autovacuum, |
| 73 | to_char(pg_class.reltuples, '9G999G999G999') AS n_tup, |
| 74 | to_char(psut.n_dead_tup, '9G999G999G999') AS dead_tup, |
| 75 | to_char(CAST(current_setting('autovacuum_vacuum_threshold') AS bigint) |
| 76 | + (CAST(current_setting('autovacuum_vacuum_scale_factor') AS numeric) |
| 77 | * pg_class.reltuples), '9G999G999G999') AS av_threshold, |
| 78 | CASE |
| 79 | WHEN CAST(current_setting('autovacuum_vacuum_threshold') AS bigint) |
| 80 | + (CAST(current_setting('autovacuum_vacuum_scale_factor') AS numeric) |
| 81 | * pg_class.reltuples) < psut.n_dead_tup |
| 82 | THEN '*' |
| 83 | ELSE '' |
| 84 | END AS expect_av |
| 85 | FROM pg_stat_user_tables psut |
| 86 | JOIN pg_class on psut.relid = pg_class.oid |
| 87 | ORDER BY 1; |
| 88 | }}} |