pg_database_size()
essentially queries the filesystem for the size of $PGDATA/base/oid-of-database
(the per-database data directory), plus the size of every such directory in non-default tablespaces added with CREATE TABLESPACE
. If there are files in these directories that don't pertain to any relation , they will be counted too. https://dba.stackexchange.com/questions/121804/what-parts-make-up-pg-database-sizeSELECT current_database() as db;
SELECT pg_database_size(current_database()) as size;
SELECT pg_size_pretty(pg_database_size(current_database())) as size;
SELECT SUM(pg_total_relation_size(oid)) AS dbsize,
pg_database_size(current_database()) AS dbsizeondisk
FROM pg_class
WHERE relkind IN ('r','m','S')
AND NOT relisshared;
jira
1714780696
1635 MB
1731985408
1732098584