GP - function to report on AO tables bloated tables which may require Vacuum
To view AO table bloat view click here
SCHEMANAME
TABLENAME
env PGOPTIONS="-c client_min_messages=WARNING" psql $PSQL_CONN_PARMS -c
"select
nspname as \"Schema\", relname as \"Table\",
count(*) as \"# files\",
sum(case when compaction_possible='t' then 1 else 0 end) as \"# files compactible\",
max(percent_hidden) as \"Max % of Hidden Rows\"
from (select
n.nspname,
c.relname,
(gp_toolkit.__gp_aovisimap_compaction_info(c.oid)).*
from pg_class c
join pg_namespace n
on n.oid = c.relnamespace
where nspname like lower('$SCHEMANAME')
and relname like lower('$TABLENAME')
and array_to_string(c.reloptions,',') like '%appendonly=true%'
) a
group by
nspname, relname
order by
nspname, 5 desc"
Comments
Post a Comment