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 1pHPHR-0003mz-TU for pgsql-general@arkaria.postgresql.org; Mon, 16 Jan 2023 13:12:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pHPHP-0002MV-UI for pgsql-general@arkaria.postgresql.org; Mon, 16 Jan 2023 13:12:03 +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 1pHPHP-0002MM-KI for pgsql-general@lists.postgresql.org; Mon, 16 Jan 2023 13:12:03 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pHPHM-0007tu-OU for pgsql-general@lists.postgresql.org; Mon, 16 Jan 2023 13:12:02 +0000 Received: by mail-ej1-x633.google.com with SMTP id az20so48904191ejc.1 for ; Mon, 16 Jan 2023 05:12:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; 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=KCNHx2FetWDB/WLZsXPrd/8S7VqoTbed/rllTosq8X8=; b=i3/+OnCjYf484NBeNYZNcIzbcaePLsSlP9xoXSBxTdOaZwG2xfTKW/AgjJv1M8pTOm 7EgXsKuhmrLEibdpvclc0XuQ+mSYEcQXbozoN/pr+aAmulMBB2sPk+ZxET4jGFvWvRMP GceWgnYJKQrLG8qUqznAm2fuhgbrK6n06U4i5qAO97ek5QPP5oAxWUlxnNnI/AddlFUn ouU8WVvVKtPFUiQBgBvgfDhueo+jGjmy8JLQrQUf5zEpxrtK3c2lJIKq2XkWZG/vDKbr D1/FiKFPo5YTmRR14XwZqG7JoNnIQ5Jdb9tGwhmhqOq0YHMtazPk2ZzoD3UiLZ9+uube a1Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KCNHx2FetWDB/WLZsXPrd/8S7VqoTbed/rllTosq8X8=; b=6jGadsgg+3eRzWYHPGe2go0FiitgbGXbt95Av6qsIdJEcK4wIJSDaHLho9RMwsW0kp iygOb2eYbgMxnARdVA6Eb9dodzFNQpVVqs1sLVnzc/RMscNNT2QuNtLi1+5ub760Go9C EOJb8ht+cmnWkyTVH74qFnIAyFp8cMk6rvDsWGvOO6quMF3PmzwBZMF4IwLvTunJ/uCx NrswBdbXWe3lf9OaVdwDRpH+EpqE6tUBIU7x3S2DxA6V6jaKdJafCloHanl3sCZok3Jh ODhTy0cr1LEBdvh39Gevo5YOmfJu3ksyYSRbDGgjw2gy/BeVxnaMtRjNFjeZK+3Nxz5Y rrsQ== X-Gm-Message-State: AFqh2ko2m/PBs/4HjF/8BhBgCn0mQ0ZAbWGubMOlM4pigNK/05MyZKGN 8uo5aC+Eo/8lUW09l4xjXczP8w== X-Google-Smtp-Source: AMrXdXupsv+HsVWjg8VhuKRQuScv0447J9rEjCcjHUb9Lc1amt6ziv+cPz3w8ZRMikDb4s/PuXPllg== X-Received: by 2002:a17:906:4e43:b0:84d:3fa7:12d7 with SMTP id g3-20020a1709064e4300b0084d3fa712d7mr31345673ejw.21.1673874719749; Mon, 16 Jan 2023 05:11:59 -0800 (PST) Received: from localhost.localdomain (62-47-151-167.adsl.highway.telekom.at. [62.47.151.167]) by smtp.gmail.com with ESMTPSA id q21-20020a17090676d500b0086a2e31d1c1sm4062453ejn.28.2023.01.16.05.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 05:11:59 -0800 (PST) Message-ID: <4cd35a2737cc783662f1df14551c3dcb1bf55916.camel@cybertec.at> Subject: Re: Why is a Read-only Table Gets Autovacuumed "to prevent wraparound" From: Laurenz Albe To: Fred Habash , pgsql-general@lists.postgresql.org Date: Mon, 16 Jan 2023 14:11:58 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-01-16 at 07:48 -0500, Fred Habash wrote: > This is a puzzle I have not been able to crack yet.=C2=A0 >=20 > We have a single-page table with 28 rows that is purely read-only. There = isn't a way in postgres to make a table RO, but I say this with confidence = because=C2=A0pg_stat_user_tables has always showed 0 > updates/deletes/inserts.=C2=A0 >=20 > Furthermore, the schema app developers know, for certain, this table does= not get changed at all.=C2=A0 >=20 > We installed scripts that run every few minutes that do a 'select *' and = over a period of days, we have not seen a change. >=20 > We disabled autovacuum on this table '{autovacuum_enabled=3Dfalse}'. But,= despite the fact that this table is read-only (by design) and autovac id i= s disabled, it got autovac'd twice in less than=C2=A010 > days and on both occasions, pg_stat_activity showed the worker with 'to p= revent wraparound'. This explains why autovac did not honor the disabled st= atus.=C2=A0 >=20 > But why is this table autovac'd=C2=A0at all?=C2=A0 For every table PostgreSQL stores the oldest transaction ID in an unfrozen = tuple in "pg_class.relfrozenxid". Once that is more than "autovacuum_freeze_max_= age", the table gets autovacuumed. If the table is already all-frozen, that is a= short operation and will just advance "pg_class.relfrozenxid". Yours, Laurenz Albe