Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGsAc-000X9d-I0 for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 03:27:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sGsAb-001azE-4u for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 03:27:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGsAa-001az6-Pu for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 03:27:37 +0000 Received: from mail-vs1-xe2e.google.com ([2607:f8b0:4864:20::e2e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGsAZ-0012Gr-Hv for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 03:27:37 +0000 Received: by mail-vs1-xe2e.google.com with SMTP id ada2fe7eead31-48c4c15e57fso498976137.3 for ; Mon, 10 Jun 2024 20:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718076454; x=1718681254; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=RzBBudFuBhN057swrwcFG8U1CKI5MOSmT706y23Xufg=; b=hr5lCcqT6OKTAgQ8igARp/eFoYzbcfv2muOrIOnv7OIXLh+8Wmcpc5XhqWYOLxk4Fg iRsGCQlQB3EnJ7vWAZ55u8M9qYz2XAoIocdtrNHBrJCnTqnwcfR4cVeWhHli0sVMuy33 /1t3Clkkc1kJFPFZn3ekybAVOnAkTdXZWfj6CH1dIvpgvr1oG3W99EXdU4I8O2uxSq33 jhWQVX5LKB6/O4A33oMQJvibm0MX+6l3lfwqsJ7P6NCadtuGUzsT3AdT2LwSFuL85Ul1 SdDlKeb2xllkFPyT/VDfJhUr/+0U4SVz+l7v2JCnC9kzil/NZD8KHn7L6M622Io4o+mz H9sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718076454; x=1718681254; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RzBBudFuBhN057swrwcFG8U1CKI5MOSmT706y23Xufg=; b=PmcB4/qIj6MfFkikrL0c/5LaR72kdx3wp+D4y4R2ESFXTWDdia7YEV/myaKqfQIwN+ FLp7dIUlQmP0ovu8cp99PYOS0rFXrFhYAJw6DDqk4C7oiz/qsK/+LcRoVRoI05N6HAwD fGc41JigIEK4T5LhRGp1uqmzYqaOIo1YqdX9/OVgT+1y/bLPX1WtWJaltsJUXl/osVer eoFsoc+1tH7VN23gXIAnxT0wknUOG6Nq0cLrjAp8fDz97AIqcnJzYYFnRZkouXoKqv1N +OUbkwPuYdCpuIyqMGy++94wqCH1A3fMaxJ2shN9QHuLykB5PQHJnMn+st66SFSKUqvk 6Hfg== X-Gm-Message-State: AOJu0YwIK1cPApvn1uM01K8pzT0gFlltnQJoi5BEkCXv9WI67++Mpc2N V1Ogvsg99Hb7s6n0og5LgoNTNVBkjtXV3m8m3R5U1A+njTXcZQcT/qxNbjmwWO7dk+VdJygDZfp wA4HkqTkYQskN3pjtw6Yfd3uOTqg= X-Google-Smtp-Source: AGHT+IFqgMDxXsI2Btt3XufSiSOIXyiLBTj+prymSVEmMiYV+xeANfOoGmt2PGde3yTQgAffHKlvljfoIU7QJ1t5HQw= X-Received: by 2002:a67:f516:0:b0:48c:482a:cc50 with SMTP id ada2fe7eead31-48c482acd34mr6469450137.21.1718076453747; Mon, 10 Jun 2024 20:27:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kashif Zeeshan Date: Tue, 11 Jun 2024 08:27:23 +0500 Message-ID: Subject: Re: Vacuum backend with backend_xmin? To: =?UTF-8?Q?Torsten_F=C3=B6rtsch?= Cc: pgsql-general Content-Type: multipart/alternative; boundary="000000000000b90813061a94d818" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b90813061a94d818 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Mon, Jun 10, 2024 at 5:07=E2=80=AFPM Torsten F=C3=B6rtsch wrote: > Hi, > > This is a VACUUM FREEZE process. > > -[ RECORD 1 ]------+-------------- > pid | 129471 > datid | 16401 > datname | feed > relid | 1889166 > phase | scanning heap > heap_blks_total | 1254901 > heap_blks_scanned | 1017524 > heap_blks_vacuumed | 0 > index_vacuum_count | 0 > max_dead_tuples | 11184809 > num_dead_tuples | 0 > backend_xid | > backend_xmin | 3267908740 > age | 8572 > > The query is: > > select v.*, a.backend_xid, a.backend_xmin, age(a.backend_xmin) > from pg_stat_progress_vacuum as v join pg_stat_activity as a on a.pid=3Dv= .pid > > Now, my question is why does a vacuum backend have a backend_xmin? I am > just curious. > it is the oldest transaction ID whose effects may not be visible to the transaction running in the backend. Since transaction IDs are stored in each row to determine its visibility, the minimum of the "backend_xmin" of all backends determines the cut-off point beyond which all backends will agree on the visibility of tuples. This is for example relevant for VACUUM: it cannot remove any dead tuples that contain a transaction ID that is not older than any backend's Regards Kashif Zeeshan Bitnine Global > > Thanks, > Torsten > --000000000000b90813061a94d818 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

On Mon, Jun 10, 2024 at 5:07=E2=80=AFPM= Torsten F=C3=B6rtsch <tfoerts= ch123@gmail.com> wrote:
Hi,

This is a VACUUM FRE= EZE process.

-[ RECORD 1 ]------+--------------
pid =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| 129471
datid =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0| 16401
datname =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0| feed
relid =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0| 1889166
phase =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0| scanning heap
heap_blks_total =C2=A0=C2=A0=C2=A0| 1254901
heap_blks_scanned =C2=A0| 1017524
heap_blks_vacuumed | 0
index_vacuum_count | 0
max_dead_tuples =C2=A0=C2=A0=C2=A0| 11184809
num_dead_tuples =C2=A0=C2=A0=C2=A0| 0
backend_xid =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| <NULL>
backend_xmin =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0| 3267908740
age =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0| 8572

The query is:

select v.*, a.backend_xi= d, a.backend_xmin, age(a.backend_xmin)
from pg_stat_pr= ogress_vacuum as v join pg_stat_activity as a on a.pid=3Dv.pid

Now, my question is why does a vacuum = backend have a backend_xmin? I am just curious.

it is the oldest transaction ID whose effects may not be
visible t= o the transaction running in the backend.

Since transaction IDs are stored in each row to determine its visibility= ,
the minimum of the "backend_xmin" of all backends determines= the cut-off
point beyond which all backends will agree on the visibilit= y of tuples.

This is for example relevant for VACUUM: it cannot remove any dead tuple= s
that contain a transaction ID that is not older than any backend's=

Regards
Kashif Zeeshan
Bitnine Global
Thanks,
Torsten
--000000000000b90813061a94d818--