Re: PostgreSQL and a Catch-22 Issue related to dead rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Lars Aksel Opsahl <Lars(dot)Opsahl(at)nibio(dot)no>, "pgsql-performance(at)lists(dot)postgresql(dot)org" <pgsql-performance(at)lists(dot)postgresql(dot)org>
Subject: Re: PostgreSQL and a Catch-22 Issue related to dead rows
Date: 2024-12-09 16:07:35
Message-ID: 3908773.1733760455@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Christophe Pettus <xof(at)thebuild(dot)com> writes:
>> On Dec 9, 2024, at 03:02, Lars Aksel Opsahl <Lars(dot)Opsahl(at)nibio(dot)no> wrote:
>> If there were a way to remove dead rows without requiring a commit from totally unrelated jobs, it would be much easier.

> (Strictly speaking, the rows you are describing are not "dead," in that they are still visible to some transaction.)

We do only very coarse-grained analysis of whether a row is "dead".
In principle, if vacuum had access to all the live snapshots of
all sessions, it could realize that a row really is dead even though
it's later than the current global xmin horizon. But discovering that
would be quite difficult and therefore expensive. Notably, sessions
would have to expose far more of their snapshot state than they do
today, and there would have to be interlocks to allow other sessions
to inspect that state safely, and that'd probably put us into much the
same sort of too-many-lock-conflicts problem that the OP has already.

I don't think there's any free lunch here. Maybe there's some
other compromise between amount-of-state-exposed versus
dead-row-discoverability, but finding a better way would take
a great deal of creative effort and testing.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Pavel Stehule 2024-12-09 16:54:26 Re: proposal: schema variables
Previous Message Christophe Pettus 2024-12-09 14:32:59 Re: PostgreSQL and a Catch-22 Issue related to dead rows