How to reclaim space occupied by unused LOBs in Po

2019-07-19 05:48发布

I have a medium sized database cluster running on PostgreSQL 8.3.

The database stores digital files (images) as LOBs.

There is a fair bit of activity in the database cluster, a lot of content is created and deleted in an ongoing manner.

Even though the application table which hosts the OIDs, gets maintained properly by the application (when an image file is deleted), the size of the database cluster grows continuously.

Auto-vacuuming is active so this shouldn't happen.

1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-19 06:07

LOBs are NOT deleted from the database when the rows of your application table (containing the OIDs) get deleted.

This also means that space will NOT be reclaimed by the VACUUM process.

In order to get rid of unused LOBs, you have run VACUUMLO on the databases. Vacuumlo will delete all of the unreferenced LOBs from a database.

Example call:

vacuumlo -U postgres -W -v <database_name>

(I only included the -v to make vacuumlo a bit more verbose so that you see how many LOBs it removes)

After vacuumlo has deleted the LOBs, you can run VACUUM FULL (or let the auto-vacuum process run).

查看更多
登录 后发表回答