如何通过每个postgres数据库获取实际分配的表空间大小?


Answers:


16

要获取数据库占用的磁盘空间(格式正确):

SELECT pg_size_pretty(pg_database_size('mydb'))

表空间占用的磁盘空间:

SELECT pg_size_pretty(pg_tablespace_size('mytblspace'))

在手册中找到有关数据库对象大小函数的更多信息:


2
可以非常有用地将其与SELECT系统表上的SELECT spcname, pg_size_pretty(pg_tablespace_size(spcname)) FROM pg_tablespace;和结合起来SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database;
jpmc26 2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.