为什么看不到我的架构大小

编程入门 行业动态 更新时间:2024-10-26 06:29:53
本文介绍了为什么看不到我的架构大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果您用Google搜索 postgresql表大小,则会得到此查询。

但未在结果中显示:

为什么 app 模式未显示在结果中?

我尝试第二个 查询 ,还限制了空结果。

从information_schema.tables 中选择table_name,pg_relation_size(table_name),其中table_schema ='app'订单2

解决方案

不幸的是,甚至psql命令l ine工具不会显示架构中所有对象的总大小。所有命令,例如用于数据库的 \l +或用于表的 \dt +,都以 +形式显示。

从pg_class中选择可能是最好的选择,但不仅针对 r进行过滤-模式还包含索引和其他对象。

If you google for "postgresql table size" you get this nice query. wiki.postgresql/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;

I have a schema app:

But doesnt show in the result:

Why app schema doesnt show in the result?

I try a second query, and also returm empty result.

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

解决方案

Unfortunately even psql command line tool does not show total size of all objects in schema. All commands like "\l+" for databases or "\dt+" for tables show in "+" form also total size. Only "\dn+" for schemas does not show size.

Select from pg_class is probably the best but do not filter only for "r" - schemas contain also indexes and other objects.

更多推荐

为什么看不到我的架构大小

本文发布于:2023-10-16 05:20:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496617.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:架构   大小

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!