Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find dead tuples size in postgresql?

Tags:

postgresql

How to find dead tuples size in postgresql ? I have created backup of database using pg_dump and restored it on other server. I see there is database size difference (5 GB)in both database. I have verified the table live tuples and dead tuples. There is numbers of row difference due to new data added in current database. However it is big difference in restored DB size. What is the cause of it ? I didn't do vacuum analyze on restored database yet.

I see there is no dead tuples on restored database this may be one reason. That's why I want to find deadtuples size.

like image 409
Darshan Shah Avatar asked Dec 31 '25 10:12

Darshan Shah


2 Answers

This is the view that you need to check:

select n_live_tup, n_dead_tup, relname from pg_stat_all_tables;  
like image 176
Frank N Stein Avatar answered Jan 08 '26 21:01

Frank N Stein


You can use the extension pgstattuple. It will report dead_tuple_len.

like image 20
jjanes Avatar answered Jan 08 '26 21:01

jjanes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!