Pruning never visible changes

From: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Pruning never visible changes
Date: 2022-09-16 12:33:23
Message-ID: CANbhV-Hhc+-A9OU6m4_-UmrFVg3urgJif-MTtETTkZORkXeqPQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

A user asked me whether we prune never visible changes, such as

BEGIN;
INSERT...
UPDATE.. (same row)
COMMIT;

Once committed, the original insert is no longer visible to anyone, so
"ought to be able to be pruned", sayeth the user. And they also say
that changing the app is much harder, as ever.

After some thought, Yes, we can prune, but not in all cases - only if
the never visible tuple is at the root end of the update chain. The
only question is can that be done cheaply enough to bother with. The
answer in one specific case is Yes, in other cases No.

This patch adds a new test for this use case, and code to remove the
never visible row when the changes are made by the same xid.

(I'm pretty sure there used to be a test for this some years back and
I'm guessing it was removed because it isn't always possible to remove
the tuple, which this new patch honours.)

Please let me know what you think.

--
Simon Riggs http://www.EnterpriseDB.com/

Attachment Content-Type Size
never_visible.v1.patch application/octet-stream 5.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2022-09-16 12:48:37 Re: Error for WITH options on partitioned tables
Previous Message Simon Riggs 2022-09-16 12:20:20 Re: SUBTRANS: Minimizing calls to SubTransSetParent()