postgresql - Vacuum analyze after huge deleting of rows not freeing space in postgres -
i delete huge amount of rows in our postgres database , ran vacuum analyze later on.
i noticed disk usage did not moved in aws rds console.
tried running query, based on table size did not move well.
select *, pg_size_pretty(total_bytes) total , pg_size_pretty(index_bytes) index , pg_size_pretty(toast_bytes) toast , pg_size_pretty(table_bytes) table ( select *, total_bytes-index_bytes-coalesce(toast_bytes,0) table_bytes ( select c.oid,nspname table_schema, relname table_name , c.reltuples row_estimate , pg_total_relation_size(c.oid) total_bytes , pg_indexes_size(c.oid) index_bytes , pg_total_relation_size(reltoastrelid) toast_bytes pg_class c left join pg_namespace n on n.oid = c.relnamespace relkind = 'r' ) ) order total_bytes desc;
is normal? or disk space not being reclaimed @ all?
vacuum reclaims storage occupied dead tuples, is, marks space inside table files , index available reuse, not free disk space.
i think want command rewrites entire table , indexes while keeping data there. cluster, or vacuum full, or 1 of forms of alter table requires table rewrite. if performance can benefit clustering on order, time it.
it locks table though, don't on live server requires uninterrupted access, unless table small , can live few seconds downtime.
Comments
Post a Comment