How to reclaim space occupied by unused LOBs in PostgreSQL

為{幸葍}努か 提交于 2019-12-10 18:53:07

问题


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:


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).



来源:https://stackoverflow.com/questions/17327489/how-to-reclaim-space-occupied-by-unused-lobs-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!