Table Bloat Estimator

Estimate table bloat from pg_stat output or pgstattuple results.

Run this query to get the data:
SELECT
  relname AS table_name,
  pg_total_relation_size(c.oid) AS total_relation_size_bytes,
  n_live_tup AS live_row_count,
  n_dead_tup AS dead_row_count,
  (SELECT avg(avg_width) FROM pg_stats WHERE tablename = c.relname) AS average_row_width,
  last_vacuum::text,
  last_autovacuum::text,
  n_mod_since_analyze
FROM pg_stat_user_tables s
JOIN pg_class c ON c.relname = s.relname
WHERE s.schemaname = 'public'
ORDER BY pg_total_relation_size(c.oid) DESC;

Want continuous PostgreSQL monitoring?

Start free with one primary or standalone PostgreSQL instance and all its databases. Monitoring, alerts, query insights, index advice, team access and every non-AI feature included. No replicas. No credit card required. New Free connections get seven days of full collection, then reduced sampling. Free and Pro include 30 days of monitoring history.