From e2487c81d0e88a9fcd825724e4fb446e1805d5e6 Mon Sep 17 00:00:00 2001 From: Maksym Buz Date: Tue, 7 Apr 2026 16:58:00 +0000 Subject: [PATCH] feat(monitoring): update partition monitoring view and json export for future_partitions --- postgresql/procedures/03_monitoring_view.sql | 5 +++-- postgresql/template/partitions.get_all.sql | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/postgresql/procedures/03_monitoring_view.sql b/postgresql/procedures/03_monitoring_view.sql index aa91444..eb77ade 100644 --- a/postgresql/procedures/03_monitoring_view.sql +++ b/postgresql/procedures/03_monitoring_view.sql @@ -9,6 +9,7 @@ SELECT c.table_name, c.period, c.keep_history, + c.future_partitions AS configured_future_partitions, count(child.relname) AS partition_count, count(child.relname) FILTER ( WHERE @@ -19,7 +20,7 @@ SELECT (c.period = 'week' AND child.relname > (parent.relname || '_p' || to_char(date_trunc('week', now() AT TIME ZONE 'UTC'), 'YYYYMMDD'))) OR (c.period LIKE '%hour%' AND child.relname > (parent.relname || '_p' || to_char(now() AT TIME ZONE 'UTC', 'YYYYMMDDHH24'))) - ) AS future_partitions, + ) AS actual_future_partitions, sum(pg_total_relation_size(child.oid)) AS total_size_bytes, pg_size_pretty(sum(pg_total_relation_size(child.oid))) AS total_size, min(child.relname) AS oldest_partition, @@ -30,4 +31,4 @@ JOIN pg_class parent ON parent.relname = c.table_name LEFT JOIN pg_inherits ON pg_inherits.inhparent = parent.oid LEFT JOIN pg_class child ON pg_inherits.inhrelid = child.oid WHERE parent.relkind = 'p' -- Only partitioned tables -GROUP BY parent.relname, c.table_name, c.period, c.keep_history, c.last_updated; +GROUP BY parent.relname, c.table_name, c.period, c.keep_history, c.future_partitions, c.last_updated; diff --git a/postgresql/template/partitions.get_all.sql b/postgresql/template/partitions.get_all.sql index 3276b50..15653b7 100644 --- a/postgresql/template/partitions.get_all.sql +++ b/postgresql/template/partitions.get_all.sql @@ -2,7 +2,8 @@ SELECT table_name, period, keep_history::text AS keep_history, - future_partitions, + configured_future_partitions, + actual_future_partitions, total_size_bytes, EXTRACT(EPOCH FROM (now() - last_updated)) AS age_seconds FROM partitions.monitoring; \ No newline at end of file