PG对象查看

查看表对象大小

复制代码
SELECT pg_size_pretty(pg_relation_size('mhrordhu_shk.mut_kharedi_audit'));
 pg_size_pretty
----------------
 238 MB
(1 row)
SELECT pg_size_pretty(pg_total_relation_size('mhrordhu_shk.mut_kharedi_audit'));
 pg_size_pretty
----------------
 268 MB
(1 row)
复制代码

  获取 Postgres 中所有数据库的列表及其大小(以 GB 为单位),按最大大小排序

SELECT pg_database.datname as "database_name", pg_database_size(pg_database.datname)/1024/1024/1024 AS size_in_GB FROM pg_database ORDER by size_in_GB DESC;
 database_name | size_in_gb
---------------+------------
 mumbai        |        422
 template1     |          0
 template0     |          0
(3 rows)

 

使用元命令获取 Postgres 中所有数据库及其大小的列表

nellore=# \l+

 

 查找当前数据库中所有表大小的脚本。

SELECT
    table_schema || '.' || table_name AS TableName,
    pg_size_pretty(pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')) AS TableSize
FROM information_schema.tables
ORDER BY
    pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC

 

posted @   wongchaofan  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2020-07-20 ubuntu安装mysql5.7的时候提示mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
2020-07-20 ubuntu版本scp连接Permission denied, please try again.问题
点击右上角即可分享
微信分享提示