pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Marcos Pegoraro <marcos@f10.com.br>
To: Postgres General <pgsql-general@postgresql.org>
Subject: Re: vacuum to prevent wraparound
Date: Tue, 06 Jun 2023 18:52:15 +0200
Message-ID: <f853768ada725f311efc72fd15a6efd918d429f1.camel@cybertec.at> (raw)
In-Reply-To: <CAB-JLwZ3pSJmGTMuTcG0sSMf2S2Wfi++3DQfbmYYaWrH9dxvtA@mail.gmail.com>
References: <CAB-JLwZ3pSJmGTMuTcG0sSMf2S2Wfi++3DQfbmYYaWrH9dxvtA@mail.gmail.com>

On Tue, 2023-06-06 at 11:36 -0300, Marcos Pegoraro wrote:
> I have a replica server using Postgres 14.4.
> Replica is done using Publication/Subscription and I have triggers for auditing,
> so every record which comes from production is audited.
> Some months ago I changed the way I was auditing and replaced that audit table
> for a new one, but didn't remove the old table. So I have both, new (AUDIT) and
> old (SYS_AUDIT) tables. 
> Then last night I received this message that to prevent wraparound postgres would
> do an aggressive vacuum on (SYS_AUDIT), and that took several hours to complete,
> in a table that is not used for 6 or 8 months. Why ?

Because otherwise the rows in that table would suffer data corruption at some point.
See https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND

PostgreSQL doesn't know what you don't need these data any more.

> I know it would be good to run vacuum on that table, it has lots of dead tuples,
> but that table is not used anymore, so why vacuum it ?

This is not about dead tuples at all.

> I have to drop immediately that huge table that is not used anymore because it can
> stop the server to prevent a wraparound some day ?

No, you don't have to drop it.

If you know that the table will not change any more, you can run

  VACUUM (FREEZE) tablename;

That will be as intense as the anti-wraparound autovacuum that caused your concern,
but afterwards you will never again have a long-running, intense autovacuum run on
that table.

Yours,
Laurenz Albe





view thread (2+ messages)

Message-ID: <f853768ada725f311efc72fd15a6efd918d429f1.camel@cybertec.at>
Permalink:  ../f853768ada725f311efc72fd15a6efd918d429f1.camel@cybertec.at/
Also on:    postgresql.org/message-id/f853768ada725f311efc72fd15a6efd918d429f1.camel@cybertec.at

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, marcos@f10.com.br
  Subject: Re: vacuum to prevent wraparound
  In-Reply-To: <f853768ada725f311efc72fd15a6efd918d429f1.camel@cybertec.at>
  References: <CAB-JLwZ3pSJmGTMuTcG0sSMf2S2Wfi++3DQfbmYYaWrH9dxvtA@mail.gmail.com> <f853768ada725f311efc72fd15a6efd918d429f1.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