Xupeng's blog

圆外之大,心向往之

汗,postgresql从8.1就提供了查看物理存储空间的函数了……

http://www.postgresql.org/docs/8.1/interactive/functions-admin.html 比如:
=> SELECT pg_database_size('myproject');
 pg_database_size
------------------
          9641188
(1 row)

=> SELECT pg_relation_size('mytable');
 pg_relation_size
------------------
             8192
(1 row)
还可以显示为更易读的格式:
=> SELECT pg_size_pretty(pg_database_size('myproject'));
 pg_size_pretty
----------------
 9415 kB
(1 row)
=> SELECT pg_size_pretty(pg_relation_size('mytable'));
 pg_size_pretty
----------------
 8192 bytes
(1 row)

Comments