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

From: Hannu Krosing <hannuk(at)google(dot)com>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Lars Aksel Opsahl <Lars(dot)Opsahl(at)nibio(dot)no>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christophe Pettus <xof(at)thebuild(dot)com>, "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-10 20:26:11
Message-ID: CAMT0RQQY4cuJGRWJ5C9zzaXZEfqyb+WfxOai6hVJ-R9wDSaM1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

If there are unremovable rows it usually also means that index-only scan
degrades to index-scan-with-visibility-checks-in-tables.

I think the ask is to be able to remove the recently dead rows that are not
visible in any current snapshot and can never become visible to any future
snapshot,
Something that Tom described as currently not easily doable above.

Maybe we could figure out a way for long-running transactions to upload
their snapshot set to some meta-vacuum process which can use it to
determine which rows fall into that category. In this way the change would
affect only the long-running transactions and if we do it onl maybe once a
minute it should not be too heavy overhead even for these transactions.

On Tue, Dec 10, 2024 at 4:32 PM Greg Sabino Mullane <htamfids(at)gmail(dot)com>
wrote:

> Thanks for that link; seeing actual queries is a big help. One thing to
> try is to get some index-only scans to run. Regular indexes need to consult
> the heap (main table) for visibility information, and a bloated table can
> make that consultation expensive.
>
> For example, an index like this should work to trigger an index-only scan:
>
> create index gregtest on node(geom) include(node_id) where
> containing_face=0;
>
> For those not following that link, the query is:
>
> SELECT node_id, geom FROM node WHERE containing_face IN (0)
> AND geom &&
> '0102000020A21000000200000025DDA6B95DC62540F4E713991CE84D4017EE7636A3C625404E468D0D23E84D40'::geometry
>
> Or if containing_face is not always 0, a more generic variant:
>
> create index gregtest on node(geom, containing_face) include (node_id);
>
> What is the nature of the updates that are causing that many dead rows in
> the first place?
>
> Cheers,
> Greg
>
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Lars Aksel Opsahl 2024-12-11 07:32:52 Re: PostgreSQL and a Catch-22 Issue related to dead rows
Previous Message Greg Sabino Mullane 2024-12-10 15:31:37 Re: PostgreSQL and a Catch-22 Issue related to dead rows