Re: non-HOT update not looking at FSM for large tuple update

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
Cc: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Floris Van Nee <florisvannee(at)optiver(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: non-HOT update not looking at FSM for large tuple update
Date: 2021-03-12 12:45:38
Message-ID: CAEze2Wjn_BK6VGX3ZYnHndMqUz07K0W7X8MzGH2X_Ek1tn1tyQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 11 Mar 2021 at 16:16, John Naylor <john(dot)naylor(at)enterprisedb(dot)com> wrote:
>
> On Thu, Mar 11, 2021 at 9:46 AM Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> wrote:
>
> > Regarding the 2% slack logic, could we change it to use increments of
> > line pointers instead? That makes it more clear what problem this
> > solution is trying to work around; that is to say line pointers not
> > (all) being truncated away. The currently subtracted value accounts
>
> That makes sense.
>
> > ...
> > - if (len + saveFreeSpace > MaxHeapTupleSize)
> > + if (len + saveFreeSpace > maxPaddedFsmRequest)
> > ...
> > - targetFreeSpace = Max(len, MaxHeapTupleSize - (MaxHeapTupleSize * 2 / 100));
> > + targetFreeSpace = Max(len, maxPaddedFsmRequest);
> > ...
>
> If we have that convenient constant, it seems equivalent (I think) and a bit more clear to write it this way, but I'm not wedded to it:
>
> if (len + saveFreeSpace > MaxHeapTupleSize &&
> len <= maxPaddedFsmRequest)
> {
> ...
> targetFreeSpace = maxPaddedFsmRequest;
> }

+ else if (len > maxPaddedFsmRequest
+ {
+ /* request len amount of space; it might still fit on
not-quite-empty pages */
+ targetFreeSpace = len;
+ }

If this case isn't added, the lower else branch will fail to find
fitting pages for len > maxPaddedFsmRequest tuples; potentially
extending the relation when there is actually still enough space
available.

> else
> targetFreeSpace = len + saveFreeSpace;

> Also, should I write a regression test for it? The test case is already available, just no obvious place to put it.

I think it would be difficult to write tests that exhibit the correct
behaviour on BLCKSZ != 8196. On the other hand, I see there are some
tests that explicitly call out that they expect BLCKSZ to be 8192, so
that has not really been a hard block before.

The previous code I sent had initial INSERT + DELETE + VACUUM. These
statements can be replaced with `INSERT INTO t_failure (b) VALUES
(repeat('1', 95)); VACUUM;` for simplicity. The vacuum is still needed
to populate the FSM for the new page.

With regards,

Matthias van de Meent

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2021-03-12 12:47:18 Re: posgres 12 bug (partitioned table)
Previous Message Andrey Borodin 2021-03-12 12:44:02 Re: MultiXact\SLRU buffers configuration