]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Reduce size of CompactAttribute struct to 8 bytes
authorDavid Rowley <drowley@postgresql.org>
Tue, 17 Mar 2026 02:06:31 +0000 (15:06 +1300)
committerDavid Rowley <drowley@postgresql.org>
Tue, 17 Mar 2026 02:06:31 +0000 (15:06 +1300)
commitd8a859d22b1accd8ea749394a488e4de014b2396
tree9b8691c768e14e5351d533b8926ec6820d38d994
parentd927b4bd97c8087c26254cb29a59c8b768cc6bd7
Reduce size of CompactAttribute struct to 8 bytes

Previously, this was 16 bytes.  With the use of some bitflags and by
reducing the attcacheoff field size to a 16-bit type, we can halve the
size of the struct.

It's unlikely that caching the offsets for offsets larger than what will
fit in a 16-bit int will help much as the tuple is very likely to have
some non-fixed-width types anyway, the offsets of which we cannot cache.

Shrinking this down to 8 bytes helps by accessing fewer cachelines when
performing tuple deformation.  The fields used there are all fully
fledged fields, which don't require any bitmasking to extract the value
of.  It also helps to more efficiently calculate the address of a
compact_attrs[] element in TupleDesc as the x86 LEA instruction can work
with 8 byte offsets, which allows the element address to be calculated
from the TupleDesc's address in a single instruction using LEA's
concurrent shift and add.

Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAApHDvodSVBj3ypOYbYUCJX%2BNWL%3DVZs63RNBQ_FxB_F%2B6QXF-A%40mail.gmail.com
src/backend/access/common/tupdesc.c
src/backend/executor/execTuples.c
src/include/access/tupdesc.h