【发布时间】:2017-04-20 01:17:45
【问题描述】:
如果你用谷歌搜索“postgresql 表大小”,你会得到这个很好的查询。 https://wiki.postgresql.org/wiki/Disk_Usage
SELECT *, pg_size_pretty(total_bytes) AS total
, pg_size_pretty(index_bytes) AS INDEX
, pg_size_pretty(toast_bytes) AS toast
, pg_size_pretty(table_bytes) AS TABLE
FROM (
SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (
SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME
, c.reltuples AS row_estimate
, pg_total_relation_size(c.oid) AS total_bytes
, pg_indexes_size(c.oid) AS index_bytes
, pg_total_relation_size(reltoastrelid) AS toast_bytes
FROM pg_class c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE relkind = 'r'
) a
) a;
我有一个架构app:
但没有显示在结果中:
为什么app 架构没有显示在结果中?
我尝试第二个query,也返回空结果。
select table_name, pg_relation_size(table_name)
from information_schema.tables
where table_schema = 'app'
order by 2
【问题讨论】:
-
app不包含任何表格。如果是这样,您会在结果中看到它们。 -
@NickBarnes 你说得对,应用只有功能和类型。
标签: postgresql schema postgresql-9.3