DBA Hub

📋Steps in this guide1/1

Find how much bloating a table has

-- Create the pgstattuple extension:

postgresql configurationintermediate
by PostgreSQL
19 views
1

Find how much bloating a table has

-- Create the pgstattuple extension: -- bloating percentage of the table "test": -- bloating percentage of index "test_x_idx":

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)

Comments (0)

Please to add comments

No comments yet. Be the first to comment!