gpt4 book ai didi

postgresql - 为什么看不到我的模式大小

转载 作者:行者123 更新时间:2023-11-29 13:51:12 25 4
gpt4 key购买 nike

如果你用谷歌搜索“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:

enter image description here

但没有显示在结果中:

enter image description here

为什么 app schema 没有显示在结果中?

我再试一次query , 并返回空结果。

select table_name, pg_relation_size(table_name)
from information_schema.tables
where table_schema = 'app'
order by 2

最佳答案

不幸的是,即使是 psql 命令行工具也不会显示模式中所有对象的总大小。所有命令,如用于数据库的“\l+”或用于表的“\dt+”,都以“+”形式显示总大小。只有模式的“\dn+”不显示大小。

从 pg_class 中选择可能是最好的,但不要只过滤“r”——模式还包含索引和其他对象。

关于postgresql - 为什么看不到我的模式大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40977776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com