Files
Iain Sproat 55d51bd84f feat(db monitor): adds a new metric speckle_db_tablesize with db table sizes (#2474)
* feat(db queries): adds db query scripts for determining db sizes

* Adds a new metric `speckle_db_tablesize` with db table sizes

* lower case all the file types to provide a combined metric

* group file status count by lower cased file type

* reinstate accidentally deleted metric

* Fix developer script
2024-07-05 15:12:27 +01:00

19 lines
488 B
SQL

SELECT
schema_name,
relname,
pg_size_pretty(table_size) AS size,
table_size
FROM (
SELECT
pg_catalog.pg_namespace.nspname AS schema_name,
relname,
pg_relation_size(pg_catalog.pg_class.oid) AS table_size
FROM pg_catalog.pg_class
JOIN pg_catalog.pg_namespace ON relnamespace = pg_catalog.pg_namespace.oid
) t
WHERE schema_name NOT LIKE 'pg_%'
AND schema_name NOT LIKE 'information_schema'
ORDER BY table_size DESC;