sql文1:
SELECT relname,reltuples,(relpages / 128) as mbytes,(relpages * 8192.0 / (reltuples + 1e-10)) as average_row_size FROM pg_class ORDER BY mbytes DESC;
sql文2:
SELECT pgn.nspname,relname,pg_size_pretty(relpages::bigint * 8 * 1024) AS size,CASE WHEN relkind = 't' THEN (SELECT pgd.relname FROM pg_class pgd WHERE pgd.reltoastrelID = pg.oID) WHEN nspname = 'pg_toast' AND relkind = 'i' THEN (SELECT pgt.relname FROM pg_class pgt WHERE SUBSTRING(pgt.relname FROM 10) = REPLACE(SUBSTRING(pg.relname FROM 10),'_index','')) ELSE (SELECT pgc.relname FROM pg_class pgc WHERE pg.reltoastrelID = pgc.oID) END::varchar AS refrelname,CASE WHEN nspname = 'pg_toast' AND relkind = 'i' THEN (SELECT pgts.relname FROM pg_class pgts WHERE pgts.reltoastrelID = (SELECT pgt.oID FROM pg_class pgt WHERE SUBSTRING(pgt.relname FROM 10) = REPLACE(SUBSTRING(pg.relname FROM 10),''))) END AS relIDxrefrelname,relfilenode,relkind,reltuples::bigint,relpages FROM pg_class pg,pg_namespace pgn WHERE pg.relnamespace = pgn.oID AND pgn.nspname NOT IN ('information_schema','pg_catalog') ORDER BY relpages DESC;总结
以上是内存溢出为你收集整理的PostgreSQL获取表的Size全部内容,希望文章能够帮你解决PostgreSQL获取表的Size所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)