drop table if exists t; create table t (a int, b int); insert into t (select a, (random() * 100000)::int from generate_series((select count(*) from t) + 1, 1000000) a); update t set b = b + 1 where a < (select count(*) from t) * 0.7; vacuum t; delete from t where a < (select count(*) from t) * 0.99; vacuum t; select c.relpages, s.n_live_tup, c.reltuples, (select count(*) from t) as tuples, reltuples::float / (select count(*) from t) as ratio from pg_stat_user_tables s, pg_class c where s.relname = 't' and c.relname = 't';