From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Avihai Shoham <avihai.shoham@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: Autovacuum script
Date: Thu, 07 Apr 2022 12:27:42 +0200
Message-ID: <49a74a198068f02c507f2a5e4c533cc30d24adc6.camel@cybertec.at> (raw)
In-Reply-To: <CA+=0ERct5Orv+GeERiROr4n+EXVi1=V+iQTnozb5qY+e_MaCFQ@mail.gmail.com>
References: <CA+=0ERcG7nz7N-sEPDsKzNn+aMC+Rt2oy=sXe94ieoG61x-W2Q@mail.gmail.com>
<CA+=0ERct5Orv+GeERiROr4n+EXVi1=V+iQTnozb5qY+e_MaCFQ@mail.gmail.com>
On Thu, 2022-04-07 at 12:36 +0300, Avihai Shoham wrote:
> I would like for you advice/sharing about a python script that will run overnight and do autovacuum.
>
> I'm sharing mine below and will happy if you have suggestion to improve it , or sharing yours in case you have.
> I'm not an expert of python or postgrsql so please understand :)
>
> The script below do autovacuum for the biggest 10 tables
> -----------------------------------------------------------------------------------------------------------------------------------
> #!/usr/bin/python
> [...]
> query = 'VACUUM FULL %s;' % (row[0])
I think that is quite a bad idea, for several reasons:
1. VACUUM (FULL) blocks read access to the table and is *not* a routine maintenance job
It should be VACUUM instead.
2. It may not be your largest tables that require VACUUM
3. There already is an autovacuum daemon in PostgreSQL that takes care of that and
has many parameters to adapt it to your needs.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.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: laurenz.albe@cybertec.at, avihai.shoham@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: Autovacuum script
In-Reply-To: <49a74a198068f02c507f2a5e4c533cc30d24adc6.camel@cybertec.at>
* 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