From: Guillaume Lelarge <guillaume@lelarge.info>
To: Nilesh Govindarajan <lists@itech7.com>
Cc: Scott Marlowe <scott.marlowe@gmail.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Execute VACUUM FULL when DB touches a specific size ?
Date: Mon, 05 Apr 2010 08:29:15 +0200
Message-ID: <4BB9833B.3080005@lelarge.info> (raw)
In-Reply-To: <4BB9624D.7010600@itech7.com>
References: <4BB94934.3050709@itech7.com>
<j2idcc563d11004042024w10c18f0etb2738c62290a663b@mail.gmail.com>
<4BB9624D.7010600@itech7.com>
Le 05/04/2010 06:08, Nilesh Govindarajan a écrit :
> On 04/05/10 08:54, Scott Marlowe wrote:
>> On Sun, Apr 4, 2010 at 8:21 PM, Nilesh Govindarajan<lists@itech7.com>
>> wrote:
>>> Hi,
>>>
>>> I wish to execute VACUUM FULL when DB touches a specific size. How to
>>> do it
>>> ?
>>>
>>> I'm aware about the caveats of VACUUM FULL.
>>>
>>
>> Write a bash script that cds to the data dir and runs du -s, grabs the
>> value, and if it's over a certain size then run vacuum full.
>
> That's what I was thinking to do, but how do I distinguish between the
> databases ? The datadir/base seems have directories whose names are
> numbers.
>
You can find the number with a simple query (SELECT oid FROM pg_database
WHERE datname='your database name') or with the oid2name contrib module.
But that's not the real issue. If you have objects of this database in
other tablespaces, "du -sh" on datadir/base/<oid> won't count them. You
should better use this query:
SELECT pg_database_size('your database name')
to get the total size of your database.
--
Guillaume.
http://www.postgresqlfr.orghttp://dalibo.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: guillaume@lelarge.info, lists@itech7.com, scott.marlowe@gmail.com
Subject: Re: Execute VACUUM FULL when DB touches a specific size ?
In-Reply-To: <4BB9833B.3080005@lelarge.info>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox