Postgresql – Why is the postgres `base` directory filling up rapidly

postgresql

My pg_xlog directory was filling up because my standby server was down. This brought the volume to 100% usage and shut down postgres. I brought up the standby servers, moved pg_xlog to another volume, symlinked it back into the data directory, and restarted the DB. DB volume was then at 43% without pg_xlog. The standby server got caught up, pg_xlog went from 4600 files to 1100 over a couple hours and I went to bed. Standby server went down overnight again. When I woke up, pg_xlog had 11k files and growing, and the base directory had filled up the volume with 66GB to 95%.

So, where the hell did all this new data in base come from overnight?

Best Answer

To generate 10k WAL files overnight, your database is obviously very busy. It is not surprising that the non-WAL of such a busy database might also grow rapidly. Indeed, why wouldn't it? If your database were that busy but not growing, that is the weird thing which would be in need of explanation, based on what you know about how your database is used.

Do you have hot_standby_feedback turned on?

If your database is still up, you can use these queries to figure out where all the space is going, although I usually just start with '\l+' and '\dit+' in psql (those ones don't sort by size, so if you have a lot of objects to scan through, the other ones may be better). If your database is not up, you can use OS tools like 'du' and 'ls' to to figure out where the space is going. But translating file names back to table names without a running database will not be easy.