Запросы для вакуума

Автор: talifa, 31 мая, 2023

---------------------------------------   кто нуждается в вакууме
SELECT schemaname, relname, n_tup_ins as "inserts",n_tup_upd as "updates",n_tup_del as "deletes", n_live_tup as "live_tuples", n_dead_tup as "dead_tuples"
FROM pg_stat_user_tables 
--WHERE schemaname = 'scott' and relname = 'employee';
order by n_dead_tup desc;

---------------------------------------     сколько места занимает
   SELECT rolname AS owner,
      nspname AS schemaname
    , relname AS tablename
    , relpages, reltuples, (reltuples::FLOAT / relpages::FLOAT) AS tuples_per_page
FROM pg_class
JOIN pg_namespace ON relnamespace = pg_namespace.oid
JOIN pg_roles     ON relowner     = pg_roles.oid
WHERE relkind = 'r' AND relpages > 20 AND reltuples > 1000
 AND nspname != 'pg_catalog'
ORDER BY tuples_per_page;