Find how much bloating a table has
-- Create the pgstattuple extension:
postgresql configurationintermediate
by PostgreSQL
19 views
-- Create the pgstattuple extension:
1234567891011121314
postgres=#
create extension pgstattuple;
CREATE EXTENSION
postgres=#
SELECT pg_size_pretty(pg_relation_size('test')) as table_size,(pgstattuple('test')).dead_tuple_percent;
table_size. | dead_tuple_percent
------------+--------------------
1408 kBÂ Â Â | 0
(1 row)
select pg_relation_size('test_x_idx') as index_size, 100-(pgstatindex('test_x_idx')).avg_leaf_density as bloat_ratio;
index_size. | bloat_ratio
------------+--------------------
1008 kBÂ Â Â | 0
(1 row)Please to add comments
No comments yet. Be the first to comment!