Re: Expanding HOT updates for expression and partial indexes - Mailing list pgsql-hackers

From Matthias van de Meent
Subject Re: Expanding HOT updates for expression and partial indexes
Date
Msg-id CAEze2WgBxPub9hoN0=eWn4pf5Zvb=anJm2A_iEPX_abDkn6PQg@mail.gmail.com
Whole thread Raw
In response to Re: Expanding HOT updates for expression and partial indexes  ("Burd, Greg" <gregburd@amazon.com>)
Responses Re: Expanding HOT updates for expression and partial indexes
List pgsql-hackers
On Mon, 10 Feb 2025 at 19:15, Burd, Greg <gregburd@amazon.com> wrote:
>
> Apologies for not being clear, this preserves the current behavior for summarizing indexes allowing for HOT updates
whilealso updating the index.  No degradation here that I’m aware of, indeed the tests that ensure that behavior are
unchangedand pass. 

Looking at the code again, while it does indeed preserve the current
behaviour, it doesn't actually improve the behavior for summarizing
indexes when that would be expected.

Example:

CREATE INDEX hotblocking ON mytab USING btree((att1->'data'));
CREATE INDEX summarizing ON mytab USING BRIN(att2);
UPDATE mytab SET att1 = att1 || '{"check": "mate"}';

In v3 (same code present in v4), I notice that in the above case we
hit the "indexed attribute updated" path (hotblocking indeed indexes
the updated attribute att1), go into ExecIndexesRequiringUpdates, and
mark index 'summarizing' as 'needs an update', even though no
attribute of that index has a new value. Then we notice that
att1->'data' hasn't changed, and so we don't need to update the
'hotblocking' index, but we do update the (unchanged) 'summarizing'
index.

This indicates that in practice (with this version of the patch) this
will improve the HOT applicability situation while summarizing indexes
don't really gain a benefit from this - they're always updated when
any indexed column is updated, even if we could detect that there were
no changes to any indexed values.

Actually, you could say we find ourselves in the counter-intuitive
situation that the addition of the 'hotblocking' index whose value
were not updated now caused index insertions into summarizing indexes.

Kind regards,

Matthias van de Meent
Neon (https://neon.tech)



pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation
Next
From: Andres Freund
Date:
Subject: Re: AIO v2.3