@@ -69,9 +69,21 @@ select
6969 case is_na when true then ' TRUE' else ' ' end as " Is N/A" ,
7070 coalesce(nullif(schema_name, ' public' ) || ' .' , ' ' ) || table_name as " Table" ,
7171 pg_size_pretty(real_size::numeric ) as " Size" ,
72- ' ~' || pg_size_pretty(extra_size::numeric )::text || ' (' || round(extra_ratio::numeric , 2 )::text || ' %)' as " Extra" ,
73- ' ~' || pg_size_pretty(bloat_size::numeric )::text || ' (' || round(bloat_ratio::numeric , 2 )::text || ' %)' as " Bloat" ,
74- ' ~' || pg_size_pretty((real_size - bloat_size)::numeric ) as " Live" ,
72+ case
73+ when extra_size::numeric >= 0
74+ then ' ~' || pg_size_pretty(extra_size::numeric )::text || ' (' || round(extra_ratio::numeric , 2 )::text || ' %)'
75+ else ' -'
76+ end as " Extra" ,
77+ case
78+ when bloat_size::numeric >= 0
79+ then ' ~' || pg_size_pretty(bloat_size::numeric )::text || ' (' || round(bloat_ratio::numeric , 2 )::text || ' %)'
80+ else ' -'
81+ end as " Bloat estimate" ,
82+ case
83+ when (real_size - bloat_size)::numeric >= 0
84+ then ' ~' || pg_size_pretty((real_size - bloat_size)::numeric )
85+ else ' -'
86+ end as " Live" ,
7587 greatest(last_autovacuum, last_vacuum)::timestamp (0 )::text
7688 || case greatest(last_autovacuum, last_vacuum)
7789 when last_autovacuum then ' (auto)'
8395 where oid = tblid
8496 ) as " Fillfactor"
8597from step4
86- order by real_size desc nulls last
98+ order by bloat_size desc nulls last
8799;
88100
89101/*
0 commit comments