Re: Deleting older versions in unique indexes to avoid page splits

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Andy Fan <zhihuifan1213(at)163(dot)com>
Cc: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Deleting older versions in unique indexes to avoid page splits
Date: 2024-11-08 00:46:53
Message-ID: CAH2-Wzn83NKUMAwYYUXdzwZF9xXqrknRFbw7pJXSCB-GEnkVbg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 7, 2024 at 7:38 PM Andy Fan <zhihuifan1213(at)163(dot)com> wrote:
> If the delete goes with Index Scan of t_b_idx, we still have the chances
> to mark hints on t_b_idx, so that it can be useful during index split?

See for yourself, by using pageinspect. The bt_page_items function
returns a "dead" column, which will be true for index tuples that
already have their LP_DEAD bit set.

The exact rules for when LP_DEAD bits are set are a bit complicated,
and are hard to describe precisely. I don't think that your DELETE
statement will set any LP_DEAD bits, because the tuples won't be dead
until some time after the xact for the DELETE statement actually
commits -- it'd have to be some later SELECT statement that runs after
the DELETE commits (could be a DELETE statement instead of a SELECT
statement but SELECT is more typical).

This also has to happen during an index scan or an index-only scan --
bitmap scans don't do it. Plus there are some other obscure rules.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-11-08 00:51:57 Re: general purpose array_sort
Previous Message Peter Geoghegan 2024-11-08 00:42:33 Re: Deleting older versions in unique indexes to avoid page splits