Include tablespace as a label for table metrics
As this will make it easier to tell where space is going.
This commit is contained in:
parent
6023aa8caf
commit
3cb8ce51fc
2 changed files with 15 additions and 6 deletions
|
|
@ -38,6 +38,7 @@ WITH RECURSIVE pg_inherit(inhrelid, inhparent) AS (
|
||||||
WHERE inhparent NOT IN (SELECT inhrelid FROM pg_inherit)
|
WHERE inhparent NOT IN (SELECT inhrelid FROM pg_inherit)
|
||||||
)
|
)
|
||||||
SELECT table_name,
|
SELECT table_name,
|
||||||
|
COALESCE(pg_tablespace.spcname,'default') AS tablespace,
|
||||||
row_estimate,
|
row_estimate,
|
||||||
table_bytes,
|
table_bytes,
|
||||||
index_bytes,
|
index_bytes,
|
||||||
|
|
@ -48,6 +49,7 @@ FROM (
|
||||||
SELECT c.oid,
|
SELECT c.oid,
|
||||||
nspname AS table_schema,
|
nspname AS table_schema,
|
||||||
relname AS table_name,
|
relname AS table_name,
|
||||||
|
reltablespace AS tablespace_id,
|
||||||
SUM(c.reltuples) OVER (partition BY parent) AS row_estimate,
|
SUM(c.reltuples) OVER (partition BY parent) AS row_estimate,
|
||||||
SUM(pg_total_relation_size(c.oid)) OVER (partition BY parent) AS total_bytes,
|
SUM(pg_total_relation_size(c.oid)) OVER (partition BY parent) AS total_bytes,
|
||||||
SUM(pg_indexes_size(c.oid)) OVER (partition BY parent) AS index_bytes,
|
SUM(pg_indexes_size(c.oid)) OVER (partition BY parent) AS index_bytes,
|
||||||
|
|
@ -58,6 +60,7 @@ FROM (
|
||||||
reltuples,
|
reltuples,
|
||||||
relname,
|
relname,
|
||||||
relnamespace,
|
relnamespace,
|
||||||
|
reltablespace,
|
||||||
pg_class.reltoastrelid,
|
pg_class.reltoastrelid,
|
||||||
COALESCE(inhparent, pg_class.oid) parent
|
COALESCE(inhparent, pg_class.oid) parent
|
||||||
FROM pg_class
|
FROM pg_class
|
||||||
|
|
@ -68,11 +71,13 @@ FROM (
|
||||||
) a
|
) a
|
||||||
WHERE oid = parent
|
WHERE oid = parent
|
||||||
AND table_schema = 'guix_data_service'
|
AND table_schema = 'guix_data_service'
|
||||||
) a;")
|
) a
|
||||||
|
LEFT JOIN pg_tablespace ON tablespace_id = pg_tablespace.oid")
|
||||||
|
|
||||||
(map (match-lambda
|
(map (match-lambda
|
||||||
((name row-estimate table-bytes index-bytes toast-bytes)
|
((name tablespace row-estimate table-bytes index-bytes toast-bytes)
|
||||||
(list name
|
(list name
|
||||||
|
tablespace
|
||||||
(or (string->number row-estimate) 0)
|
(or (string->number row-estimate) 0)
|
||||||
(or (string->number table-bytes) 0)
|
(or (string->number table-bytes) 0)
|
||||||
(or (string->number index-bytes) 0)
|
(or (string->number index-bytes) 0)
|
||||||
|
|
|
||||||
|
|
@ -146,20 +146,24 @@
|
||||||
select-load-new-guix-revision-job-metrics)))
|
select-load-new-guix-revision-job-metrics)))
|
||||||
|
|
||||||
(for-each (match-lambda
|
(for-each (match-lambda
|
||||||
((name row-estimate table-bytes index-bytes toast-bytes)
|
((name tablespace row-estimate
|
||||||
|
table-bytes index-bytes toast-bytes)
|
||||||
|
|
||||||
(metric-set table-row-estimate-metric
|
(metric-set table-row-estimate-metric
|
||||||
row-estimate
|
row-estimate
|
||||||
#:label-values `((name . ,name)))
|
#:label-values `((name . ,name)))
|
||||||
(metric-set table-bytes-metric
|
(metric-set table-bytes-metric
|
||||||
table-bytes
|
table-bytes
|
||||||
#:label-values `((name . ,name)))
|
#:label-values `((name . ,name)
|
||||||
|
(tablespace . ,tablespace)))
|
||||||
(metric-set table-index-bytes-metric
|
(metric-set table-index-bytes-metric
|
||||||
index-bytes
|
index-bytes
|
||||||
#:label-values `((name . ,name)))
|
#:label-values `((name . ,name)
|
||||||
|
(tablespace . ,tablespace)))
|
||||||
(metric-set table-toast-bytes-metric
|
(metric-set table-toast-bytes-metric
|
||||||
toast-bytes
|
toast-bytes
|
||||||
#:label-values `((name . ,name)))))
|
#:label-values `((name . ,name)
|
||||||
|
(tablespace . ,tablespace)))))
|
||||||
metric-values)
|
metric-values)
|
||||||
|
|
||||||
(metric-set revisions-count-metric
|
(metric-set revisions-count-metric
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue