Re: pgsql: Optimize tuple deformation - Mailing list pgsql-committers

From David Rowley
Subject Re: pgsql: Optimize tuple deformation
Date
Msg-id CAApHDvoLatLLOtyCjPT4uAOyuEnHTVmqDvWmMWToNeVNrgWLbg@mail.gmail.com
Whole thread
In response to Re: pgsql: Optimize tuple deformation  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: pgsql: Optimize tuple deformation
List pgsql-committers
On Wed, 7 Oct 2026 at 19:31, Peter Eisentraut <peter@eisentraut.org> wrote:
>
> On 15.03.26 23:50, David Rowley wrote:
> > Optimize tuple deformation
>
> This commit c456e391138 changed in slot_deform_heap_tuple() the type of
> attnum from int to size_t, which seems unusual and doesn't fit with the
> surrounding code.  Could you check whether that was intentional?

It was done to work around a problem with gcc where it was refusing to
index the CompactAttribute array by adding 8 to the previous address
to get the address of the next element. Instead, it was doing LEA on
each loop, which was slower due to shift and add rather than just add.
The best I could figure out is that gcc didn't want to optimise to use
LEA due to concerns about the integer wrapping around, which, if it
did, would be a different address than doing 2^31 adds on a 64-bit
pointer.

David



pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Use unconstify_constexpr
Next
From: Álvaro Herrera
Date:
Subject: pgsql: Concurrent REPACK: Clear out dropped-column values from all tupl