Re: Vacuum backend with backend_xmin?

From: Kashif Zeeshan <kashi(dot)zeeshan(at)gmail(dot)com>
To: Torsten Förtsch <tfoertsch123(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Vacuum backend with backend_xmin?
Date: 2024-06-11 03:27:23
Message-ID: CAAPsdhc+d6KMH_4PP4X1rn4Fqj_HsMWPOeMM9wh5xwrhdXzuFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

On Mon, Jun 10, 2024 at 5:07 PM Torsten Förtsch <tfoertsch123(at)gmail(dot)com>
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 | <NULL>
> 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=v.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
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2024-06-11 04:40:11 Re: Multiple tables row insertions from single psql input file
Previous Message Laurenz Albe 2024-06-11 01:41:43 Re: Does trigger only accept functions?