aboutsummaryrefslogtreecommitdiff
path: root/contrib/pageinspect
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-12-21 09:43:26 +1300
committerDavid Rowley <drowley@postgresql.org>2024-12-21 09:43:26 +1300
commitdb448ce5ad36a2754e4e75900b180260143aacf8 (patch)
tree54753cad82035c6a3cdf7edaa897291b09622d6b /contrib/pageinspect
parent1f81b48a9d567ae9074ab1f3233eae9997b3d7bd (diff)
downloadpostgresql-db448ce5ad36a2754e4e75900b180260143aacf8.tar.gz
postgresql-db448ce5ad36a2754e4e75900b180260143aacf8.zip
Optimize alignment calculations in tuple form/deform
Here we convert CompactAttribute.attalign from a char, which is directly derived from pg_attribute.attalign into a uint8, which stores the number of bytes to align the column's value by in the tuple. This allows tuple deformation and tuple size calculations to move away from using the inefficient att_align_nominal() macro, which manually checks each TYPALIGN_* char to translate that into the alignment bytes for the given type. Effectively, this commit changes those to TYPEALIGN calls, which are branchless and only perform some simple arithmetic with some bit-twiddling. The removed branches were often mispredicted by CPUs, especially so in real-world tables which often contain a mishmash of different types with different alignment requirements. Author: David Rowley Reviewed-by: Andres Freund, Victor Yegorov Discussion: https://postgr.es/m/CAApHDvrBztXP3yx=NKNmo3xwFAFhEdyPnvrDg3=M0RhDs+4vYw@mail.gmail.com
Diffstat (limited to 'contrib/pageinspect')
-rw-r--r--contrib/pageinspect/heapfuncs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c
index 8c1b7d38aa6..41ff597199c 100644
--- a/contrib/pageinspect/heapfuncs.c
+++ b/contrib/pageinspect/heapfuncs.c
@@ -357,8 +357,8 @@ tuple_data_split_internal(Oid relid, char *tupdata,
if (attr->attlen == -1)
{
- off = att_align_pointer(off, attr->attalign, -1,
- tupdata + off);
+ off = att_pointer_alignby(off, attr->attalignby, -1,
+ tupdata + off);
/*
* As VARSIZE_ANY throws an exception if it can't properly
@@ -376,7 +376,7 @@ tuple_data_split_internal(Oid relid, char *tupdata,
}
else
{
- off = att_align_nominal(off, attr->attalign);
+ off = att_nominal_alignby(off, attr->attalignby);
len = attr->attlen;
}