Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit ad06e21

Browse files
authored
[-] fix FREEZE age for partitioned tables in table_stats, fixes #760 (#783)
1 parent a0293ff commit ad06e21

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pgwatch2/metrics/table_stats/10/metric.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ with recursive /* pgwatch2_generated */
4848
autovacuum_count,
4949
analyze_count,
5050
autoanalyze_count,
51-
age(c.relfrozenxid) as tx_freeze_age
51+
case when c.relkind != 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age
5252
from pg_stat_user_tables ut
5353
join pg_class c on c.oid = ut.relid
5454
left join pg_class t on t.oid = c.reltoastrelid

pgwatch2/metrics/table_stats/16/metric.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ with recursive /* pgwatch2_generated */
4848
autovacuum_count,
4949
analyze_count,
5050
autoanalyze_count,
51-
age(c.relfrozenxid) as tx_freeze_age,
51+
case when c.relkind != 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age,
5252
extract(epoch from now() - last_seq_scan)::int8 as last_seq_scan_s
5353
from pg_stat_user_tables ut
5454
join pg_class c on c.oid = ut.relid

pgwatch2/sql/config_store/metric_definitions.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ with recursive /* pgwatch2_generated */
23042304
autovacuum_count,
23052305
analyze_count,
23062306
autoanalyze_count,
2307-
age(c.relfrozenxid) as tx_freeze_age
2307+
case when c.relkind != 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age
23082308
from pg_stat_user_tables ut
23092309
join pg_class c on c.oid = ut.relid
23102310
left join pg_class t on t.oid = c.reltoastrelid
@@ -2451,7 +2451,7 @@ with recursive /* pgwatch2_generated */
24512451
autovacuum_count,
24522452
analyze_count,
24532453
autoanalyze_count,
2454-
age(c.relfrozenxid) as tx_freeze_age,
2454+
case when c.relkind != 'p' then age(c.relfrozenxid) else 0 end as tx_freeze_age,
24552455
extract(epoch from now() - last_seq_scan)::int8 as last_seq_scan_s
24562456
from pg_stat_user_tables ut
24572457
join pg_class c on c.oid = ut.relid

0 commit comments

Comments
 (0)