postgresql 统计表数据量并整理表
select t1.relname as 表名, pg_size_pretty(pg_relation_size(relid)) as 大小, (select cast(reltuples as INTEGER) from pg_class where relkind = 'r' and relname = t1.relname) as 记录数 from pg_stat_user_tables as t1 where schemaname='course' order by pg_relation_size(relid) desc
postgresql 表会随着各种操作产生碎片数据导致表膨胀,可以执行'vacuum full'命令清理。