Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Bloating of pg_catalog.pg_attribute table

Tags:

postgresql

I have a DB that has a heavy transactional load (around 2-3 million transaction inserts per day) and each transaction insert creates several temp tables before committing the transaction.

In the process, pg_attribute table has got bloated. The number of rows in the table is less than 10k as of now, but the size is still 10GB.

I ran FULL VACUUM several times on this table, but it didn't help. Even restarted the DB and done FULL VACUUM again.

What are my options?

pg_attribute is occupying 10GB

Update

postgres=# VACUUM (VERBOSE) pg_catalog.pg_attribute;
INFO:  vacuuming "pg_catalog.pg_attribute"
INFO:  "pg_attribute": found 0 removable, 25 nonremovable row versions in 1 out of 49 pages
DETAIL:  0 dead row versions cannot be removed yet, oldest xmin: 650634809
There were 30 unused item pointers.
Skipped 0 pages due to buffer pins, 25 frozen pages.
0 pages are entirely empty.
CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s.
VACUUM
postgres=#

SELECT schemaname, relname, n_live_tup, n_dead_tup, last_autovacuum
FROM pg_stat_all_tables
ORDER BY n_dead_tup
    / (n_live_tup
       * current_setting('autovacuum_vacuum_scale_factor')::float8
          + current_setting('autovacuum_vacuum_threshold')::float8)
     DESC
LIMIT 10;

This is the result of my above query

like image 616
user1880957 Avatar asked Oct 28 '25 03:10

user1880957


1 Answers

Something is holding the tuples back. Since restarting the database didn't fix the problem, it must be something durable. To my knowledge, that would be either a prepared transaction, or a logical replication slot. So look in the pg_prepared_xacts and pg_replication_slots views.

like image 131
jjanes Avatar answered Oct 30 '25 03:10

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!