Pg查看每个表所占用磁盘空间大小
参考连接:https://blog.csdn.net/yueludanfeng/article/details/86487585
-- 方法1
select
table_full_name,
round( CAST ( size as numeric ) / 1024 / 1024 / 1024, 2 ) || 'G' 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
-- 方法2
SELECT
schemaname,
relname,
round( CAST ( pg_total_relation_size ( relid ) as numeric ) / 1024 / 1024 / 1024, 2 ) || 'G' as table_size,
n_live_tup
FROM
pg_stat_user_tables
where 1 = 1
and schemaname = 'rf_supervision'
and relname like 't_user%'
ORDER BY pg_total_relation_size ( relid ) desc
pg查询表记录数
select
relname as TABLE_NAME,
reltuples,
to_char(reltuples, 'FM99999999') as rowCounts
from
pg_class
where
relkind = 'r'
and relnamespace = ( select oid from pg_namespace where nspname = 's_system' )
--and relname = 't_user'
order by
reltuples desc;
;