iT邦幫忙

0

postgresql使用容量查詢

  • 分享至 

  • xImage

請教大家
有否工具或指令可以查詢linux上postgresql的資料表使用大小呢(每個資料表),想查詢資料庫的使用狀況,感謝

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
enen1980
iT邦研究生 1 級 ‧ 2014-09-17 09:25:31
最佳解答

EXP#
SELECT
table_schema || '.' || table_name AS table_full_name,
pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) AS size
FROM information_schema.tables
ORDER BY
pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC
REF# http://stackoverflow.com/questions/2596624/how-do-you-find-the-disk-size-of-a-postgres-postgresql-table-and-its-indexes

0
mike45218
iT邦新手 5 級 ‧ 2019-12-18 16:39:01

SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC

REF: https://wiki.postgresql.org/wiki/Disk_Usage

我要發表回答

立即登入回答