pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedExecute VACUUM FULL when DB touches a specific size ?
5+ messages / 4 participants
[nested] [flat]
* Execute VACUUM FULL when DB touches a specific size ?
@ 2010-04-05 02:21 Nilesh Govindarajan <lists@itech7.com>
0 siblings, 1 reply; 5+ messages in thread
From: Nilesh Govindarajan @ 2010-04-05 02:21 UTC (permalink / raw)
To: pgsql-admin
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.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Execute VACUUM FULL when DB touches a specific size ?
@ 2010-04-05 03:24 Scott Marlowe <scott.marlowe@gmail.com>
parent: Nilesh Govindarajan <lists@itech7.com>
0 siblings, 1 reply; 5+ messages in thread
From: Scott Marlowe @ 2010-04-05 03:24 UTC (permalink / raw)
To: Nilesh Govindarajan <lists@itech7.com>; +Cc: pgsql-admin
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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Execute VACUUM FULL when DB touches a specific size ?
@ 2010-04-05 04:08 Nilesh Govindarajan <lists@itech7.com>
parent: Scott Marlowe <scott.marlowe@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Nilesh Govindarajan @ 2010-04-05 04:08 UTC (permalink / raw)
To: Scott Marlowe <scott.marlowe@gmail.com>; +Cc: pgsql-admin
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.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Execute VACUUM FULL when DB touches a specific size ?
@ 2010-04-05 06:06 Vibhor Kumar <vibhor.aim@gmail.com>
parent: Nilesh Govindarajan <lists@itech7.com>
1 sibling, 0 replies; 5+ messages in thread
From: Vibhor Kumar @ 2010-04-05 06:06 UTC (permalink / raw)
To: Nilesh Govindarajan <lists@itech7.com>; +Cc: Scott Marlowe <scott.marlowe@gmail.com>; pgsql-admin
> 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.
Use pg_database_size function to get the size of DB.
You can create a plpgsql function, which you can schedule using pgagent
Or
If you are writing Bash script capture the return value of pg_database_size function, in some variable and perform vacuum.
Thanks & Regards,
Vibhor Kumar (PCP & OCP)
ITIL V3 Cerftified.
On 05-Apr-2010, at 9:38 AM, Nilesh Govindarajan wrote:
> 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.
>
>
>
> --
> Nilesh Govindarajan
> Site & Server Administrator
> www.itech7.com
> मेरा भारत महान !
> मम भारत: महत्तम भवतु !
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Execute VACUUM FULL when DB touches a specific size ?
@ 2010-04-05 06:29 Guillaume Lelarge <guillaume@lelarge.info>
parent: Nilesh Govindarajan <lists@itech7.com>
1 sibling, 0 replies; 5+ messages in thread
From: Guillaume Lelarge @ 2010-04-05 06:29 UTC (permalink / raw)
To: Nilesh Govindarajan <lists@itech7.com>; +Cc: Scott Marlowe <scott.marlowe@gmail.com>; pgsql-admin
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.org
http://dalibo.com
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2010-04-05 06:29 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-04-05 02:21 Execute VACUUM FULL when DB touches a specific size ? Nilesh Govindarajan <lists@itech7.com>
2010-04-05 03:24 ` Scott Marlowe <scott.marlowe@gmail.com>
2010-04-05 04:08 ` Nilesh Govindarajan <lists@itech7.com>
2010-04-05 06:06 ` Vibhor Kumar <vibhor.aim@gmail.com>
2010-04-05 06:29 ` Guillaume Lelarge <guillaume@lelarge.info>
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