Re: Database takes up MUCH more disk space than it should - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Database takes up MUCH more disk space than it should
Date
Msg-id CAOR=d=05Gu0770XxweuG_JV_AnXW3xtG=YrdLNYWVXd7G-Sobg@mail.gmail.com
Whole thread Raw
In response to Database takes up MUCH more disk space than it should  (Dan Charrois <dan001@syz.com>)
Responses Re: Database takes up MUCH more disk space than it should  (Dan Charrois <dan001@syz.com>)
List pgsql-general
On Sat, Jan 21, 2012 at 1:37 AM, Dan Charrois <dan001@syz.com> wrote:
> Hi everyone.  I'm currently in the situation of administering a rather large PostgreSQL database which for some
reasonseems to be even much larger than it should be. 
>
> I'm currently running version 8.4.5 - not the latest and greatest, I know - but this is a live database that would
problematicto take down to upgrade unless all else fails - especially considering its size if it does need to be
rebuiltsomehow. 
>
> Anyway, I'm no stranger to SQL, but new to PostgreSQL - all my SQL administration in the past has been with MySQL.
 SoI'm somewhat bumbling my way through administrative commands trying to solve this - please bear with me. 
>
> The size of the tables reported by \dt+ add up to around 120 GB.  The size of the indexes reported with \di+ adds up
toaround 15 GB.  This is pretty consistent with what I would expect the data to require. 
>
> The problem is, the disk usage of the pgsql directory where the data is kept (as reported by 'du') comes to 647 GB -
significantlymore than it should.  select pg_database_size('mydatabase') confirms this, returning 690830939920. 
>
> Vacuuming the tables (full and otherwise) hasn't helped, but then considering how the database is used, I didn't
reallyexpect it to.  It's strictly a read-only database, with the exception of once a month when it is refreshed by
loadingnew data into newly created tables, and once that is done, vacuum analyzing the new tables, dropping the old
tables,then renaming the new ones to have the name of the old ones.  Vacuums never claim to recover any space, and the
diskusage stays the same. 
>
> So how do I find out what's eating up all this extra space?

Real quick, if you run pg_database_size(name) for each db, including
template1 and postgres, what do you get back?

pgsql-general by date:

Previous
From: Szymon Guz
Date:
Subject: Re: log_statement variable does not admit all value
Next
From: Sachin Srivastava
Date:
Subject: Re: Does Stackbuilder need username/pwd for the proxy?