赞
踩
目录
- select
-
- sum(t.size)
-
- from (
-
- SELECT
-
- table_schema || '.' || table_name AS table_full_name
-
- , 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
-
- ) t
- ;
- SELECT
-
- table_schema || '.' || table_name AS table_full_name
-
- , pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') AS size_bytes
-
- , pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')/1024/1024 as size_mb
-
- , pg_total_relation_size('"' || table_schema || '"."' || table_name || '"')/1024/1024/1024 as size_gb
-
- FROM information_schema.tables
-
- ORDER by pg_total_relation_size('"' || table_schema || '"."' || table_name || '"') DESC
- ;
--查看xx数据库大小
select pg_database_size('xx');
--查看所有数据库大小
- select
- pg_database.datname
- ,pg_database_size(pg_database.datname) AS size
- from pg_database;
--查看表大小
select pg_relation_size('table_name'); --bytes
--以KB\MB\GB方式查看表大小
select pg_size_pretty(pg_relation_size('table_name'));
--查看表的总大小,包括索引大小
select pg_size_pretty(pg_total_relation_size('table_name'));
select pg_size_pretty(pg_relation_size('table_pkey'));
--查看表空间
select spcname from pg_tablespace;
--查看表空间大小
select pg_size_pretty(pg_tablespace_size('pg_default'));
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。