One of our build servers recently ran out of disc space while trying to copy an entire database. This led me to investigate the database cluster, which is stored on a RAID array with a total size of 1TB. Running a query to list all databases and their sizes did not add up to the amount of space being used by Postgres, so I had a look at the pgsql/base directory. It appears that there are a few large directories that do not correspond to any database. I wonder if these have been left behind accidentally by Postgres.

Here are the database directories:

 Size (kB)      Directory       Database

 32             pgsql_tmp
 4352           11510           template0
 4368           1               template1
 4464           11511           postgres
 5368           30103627        xav-userprofile-test
 6096           8088167         outerjoins-userprofile-12.0-copy
 8676           30103406        xav-test
 10052          31313164        common-tgt-items-kmr-modmine
 19956          1108178         modmine-3-preview-18-feb-2008
 89452          14578911        common-tgt-items-kmr
 118940         9952565         production-xav-13
 201192         1257481         common-tgt-items-gtocmine-rns
 296552         7040137         common-tgt-items-flyminebuild
 1557160        9843085
 1699624        18456655        common-src-items-flyminebuild
 3376096        278561
 3995276        9064702         production-unimine-pride-beta5
 8528136        1257482         gtocmine-rns
 40815456       29233051
 42278196       27473906
 47112412       28110832
 47913532       32728815        production-flyminebuild:ensembl-anopheles
 60519524       32841289        production-flyminebuild:go
 67626328       27377902
 69513844       32856736        production-flyminebuild:flybase-dmel-gene-fasta
 74289908       32938724        production-flyminebuild:pubmed-gene
 75786720       32941684        production-flyminebuild:biogrid
 77361800       32944072        production-flyminebuild:update-publications
 80160256       32947141        production-flyminebuild:create-references
 81333908       32574190        flybasemine-production
 86356140       12110825
 87544200       33049747        production-flyminebuild

So on this server, the wasted space takes up 276GB, which is not acceptable. I believe that if we re-initialise the cluster and re-create the databases, these directories would disappear. Taking a look at the directory 12110825, all the files inside were last accessed several months ago. So, I have a few questions:

1. Is this space used for anything, or is it just abandoned? Is this a
   bug?
2. How do I reclaim this wasted space in a safe manner?
3. How do I prevent this happening again?

Matthew

--
An ant doesn't have a lot of processing power available to it. I'm not trying
to be speciesist - I wouldn't want to detract you from such a wonderful
creature, but, well, there isn't a lot there, is there?
                                       -- Computer Science Lecturer

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Reply via email to