Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6Zux-0006i3-Ms for pgsql-general@arkaria.postgresql.org; Tue, 06 Jun 2023 16:52:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q6Zuw-0004tJ-1y for pgsql-general@arkaria.postgresql.org; Tue, 06 Jun 2023 16:52:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q6Zuv-0004tA-ND for pgsql-general@lists.postgresql.org; Tue, 06 Jun 2023 16:52:21 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1q6Zus-000cF2-KO for pgsql-general@postgresql.org; Tue, 06 Jun 2023 16:52:20 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5149390b20aso9687067a12.3 for ; Tue, 06 Jun 2023 09:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20221208.gappssmtp.com; s=20221208; t=1686070337; x=1688662337; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=G22zb+COr+aCWJi5SKa+68kfrN85TiKHv4Y5S3QC5eI=; b=N9vVdcDLDocmLUuNwI4ES7ncatKFRdYaV/kGQqIB7dgRyusNinYRv2TeJWbjnH1iS8 eNuuYVwhlH3fVv/t1fiU0daNh5vdVaVGPXKNn3Cnd6fdR2YDU1WkRV918ZLvJZ76+2Z3 uW1lQwboA/SnZIHQdXw8oCfjdEJ6Ekv0iFinJWWyfkh+g+D2W/dgS+iHhQvi+raUTnlk TPUUBtp1u8a+9XLNZrzlZMo71eC6WQIXVsY0+ZW7hTv0zA+dUBivz80qcJ8to3FQD+7i /zGFK0FEZmAegLPbTOnWo6q1cgIVB8uZs8wDnpCtZAs39OPedKD58JcO7HVg4JHnLUd8 VEoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686070337; x=1688662337; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=G22zb+COr+aCWJi5SKa+68kfrN85TiKHv4Y5S3QC5eI=; b=lJB3Pg4HAgHuoKHgIs/Ya+gNS6gRm/5utO4cs/dKy/ainpM+bdiIjSF0uZVnYkwgFX zjT8rTv/pJYHsiuHn3gtXY1d6gqNnFJzYwfKGbaiR2sT0gdpPPArv4Nr3cV5+SfHQfId v9f2WoVRWNZumvuEbsURSNFdtqlyogn+4Kd01lEaxGYZ3TO30qofdB9mY8NJzdNmNHoN xTmgsxFrfE/5V0BZw2SwKIMpnNMQ97PfcCVyMQY9aRBwZqBOmzXP7BiDrUHzdv3PVoAV Ju/bzBbnQ5qSxroeaa8/Sm5MiteFpAecCiMGY6Bjd7MZlm1k8LWIEHKPgJ2qRaHaMBE5 PWSw== X-Gm-Message-State: AC+VfDz0ajK+GnOXv3jEC2X9w2Isv37cEUWmq3OqQXL0+esHHL4s44Fg 3VSreW7lyMtvHhyGWjE3NbLuoQ== X-Google-Smtp-Source: ACHHUZ7sU01Lo+ydLUlrK9nhGsT5w5Cn7K8FHFjx4/zHHLXIyp6ah0R/JNhT/Xbqx7xk3RxUNWfj6w== X-Received: by 2002:a17:907:6d1d:b0:94b:4a4:2836 with SMTP id sa29-20020a1709076d1d00b0094b04a42836mr2850158ejc.69.1686070336813; Tue, 06 Jun 2023 09:52:16 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:379e:8bed:2c85:e152:bc3a]) by smtp.gmail.com with ESMTPSA id f18-20020a170906825200b00965ac1510f8sm5792024ejx.185.2023.06.06.09.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 09:52:16 -0700 (PDT) Message-ID: Subject: Re: vacuum to prevent wraparound From: Laurenz Albe To: Marcos Pegoraro , Postgres General Date: Tue, 06 Jun 2023 18:52:15 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 au= diting, > 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=C2=A0the old table. So I have both, new = (AUDIT) and > old (SYS_AUDIT) tables.=C2=A0 > Then last night I received this message that to prevent wraparound postgr= es would > do an aggressive vacuum=C2=A0on (SYS_AUDIT), and that took=C2=A0several h= ours 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 so= me point. See https://www.postgresql.org/docs/current/routine-vacuuming.html#VACUUM-F= OR-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 becau= se it can > stop the server to prevent a wraparound=C2=A0some 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