feat(monitoring): update partition monitoring view and json export for future_partitions
This commit is contained in:
@@ -9,6 +9,7 @@ SELECT
|
|||||||
c.table_name,
|
c.table_name,
|
||||||
c.period,
|
c.period,
|
||||||
c.keep_history,
|
c.keep_history,
|
||||||
|
c.future_partitions AS configured_future_partitions,
|
||||||
count(child.relname) AS partition_count,
|
count(child.relname) AS partition_count,
|
||||||
count(child.relname) FILTER (
|
count(child.relname) FILTER (
|
||||||
WHERE
|
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')))
|
(c.period = 'week' AND child.relname > (parent.relname || '_p' || to_char(date_trunc('week', now() AT TIME ZONE 'UTC'), 'YYYYMMDD')))
|
||||||
OR
|
OR
|
||||||
(c.period LIKE '%hour%' AND child.relname > (parent.relname || '_p' || to_char(now() AT TIME ZONE 'UTC', 'YYYYMMDDHH24')))
|
(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,
|
sum(pg_total_relation_size(child.oid)) AS total_size_bytes,
|
||||||
pg_size_pretty(sum(pg_total_relation_size(child.oid))) AS total_size,
|
pg_size_pretty(sum(pg_total_relation_size(child.oid))) AS total_size,
|
||||||
min(child.relname) AS oldest_partition,
|
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_inherits ON pg_inherits.inhparent = parent.oid
|
||||||
LEFT JOIN pg_class child ON pg_inherits.inhrelid = child.oid
|
LEFT JOIN pg_class child ON pg_inherits.inhrelid = child.oid
|
||||||
WHERE parent.relkind = 'p' -- Only partitioned tables
|
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;
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ SELECT
|
|||||||
table_name,
|
table_name,
|
||||||
period,
|
period,
|
||||||
keep_history::text AS keep_history,
|
keep_history::text AS keep_history,
|
||||||
future_partitions,
|
configured_future_partitions,
|
||||||
|
actual_future_partitions,
|
||||||
total_size_bytes,
|
total_size_bytes,
|
||||||
EXTRACT(EPOCH FROM (now() - last_updated)) AS age_seconds
|
EXTRACT(EPOCH FROM (now() - last_updated)) AS age_seconds
|
||||||
FROM partitions.monitoring;
|
FROM partitions.monitoring;
|
||||||
Reference in New Issue
Block a user