Execute VACUUM FULL when DB touches a specific size ?

Execute VACUUM FULL when DB touches a specific size ?

am 05.04.2010 04:21:40 von Nilesh Govindrajan

Hi,

I wish to execute VACUUM FULL when DB touches a specific size. How to do=20
it ?

I'm aware about the caveats of VACUUM FULL.

--=20
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत=
महान !
मम भारत: मह=
त्तम भवतु=
!

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

Re: Execute VACUUM FULL when DB touches a specific size ?

am 05.04.2010 05:24:50 von Scott Marlowe

On Sun, Apr 4, 2010 at 8:21 PM, Nilesh Govindarajan 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.

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

Re: Execute VACUUM FULL when DB touches a specific size ?

am 05.04.2010 06:08:45 von Nilesh Govindrajan

On 04/05/10 08:54, Scott Marlowe wrote:
> On Sun, Apr 4, 2010 at 8:21 PM, Nilesh Govindarajan =
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=20
databases ? The datadir/base seems have directories whose names are numbe=
rs.

--=20
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत=
महान !
मम भारत: मह=
त्तम भवतु=
!

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

Re: Execute VACUUM FULL when DB touches a specific size ?

am 05.04.2010 08:06:10 von Vibhor Kumar

> That's what I was thinking to do, but how do I distinguish between the da=
tabases ? 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=20

Or=20

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 w=
rote:
>>> Hi,
>>>=20
>>> I wish to execute VACUUM FULL when DB touches a specific size. How to d=
o it
>>> ?
>>>=20
>>> I'm aware about the caveats of VACUUM FULL.
>>>=20
>>=20
>> 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.
>=20
>=20
>=20
> --=20
> Nilesh Govindarajan
> Site & Server Administrator
> www.itech7.com
> मेरा भारत=
महान !
> मम भारत: मà=A4=
¹à¤¤à¥à¤¤à¤=AE भवतà=A5=
=81 !
>=20
> --=20
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin


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

Re: Execute VACUUM FULL when DB touches a specific size ?

am 05.04.2010 08:29:15 von Guillaume Lelarge

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=20
>> 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.
>=20
> 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.
>=20

You can find the number with a simple query (SELECT oid FROM pg_database
WHERE datname=3D'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/ 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.


--=20
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

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