aboutsummaryrefslogtreecommitdiff
path: root/src/include/access/tupmacs.h
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-12-03 16:50:59 +1300
committerDavid Rowley <drowley@postgresql.org>2024-12-03 16:50:59 +1300
commitd28dff3f6cd6a7562fb2c211ac0fb74a33ffd032 (patch)
tree4b7126eba2dcbed5e08714b4ab2d8577058814c3 /src/include/access/tupmacs.h
parente4c8865196f6ad6bb3473bcad1d2ad51147e4513 (diff)
downloadpostgresql-d28dff3f6cd6a7562fb2c211ac0fb74a33ffd032.tar.gz
postgresql-d28dff3f6cd6a7562fb2c211ac0fb74a33ffd032.zip
Introduce CompactAttribute array in TupleDesc
The new compact_attrs array stores a few select fields from FormData_pg_attribute in a more compact way, using only 16 bytes per column instead of the 104 bytes that FormData_pg_attribute uses. Using CompactAttribute allows performance-critical operations such as tuple deformation to be performed without looking at the FormData_pg_attribute element in TupleDesc which means fewer cacheline accesses. With this change, NAMEDATALEN could be increased with a much smaller negative impact on performance. For some workloads, tuple deformation can be the most CPU intensive part of processing the query. Some testing with 16 columns on a table where the first column is variable length showed around a 10% increase in transactions per second for an OLAP type query performing aggregation on the 16th column. However, in certain cases, the increases were much higher, up to ~25% on one AMD Zen4 machine. This also makes pg_attribute.attcacheoff redundant. A follow-on commit will remove it, thus shrinking the FormData_pg_attribute struct by 4 bytes. Author: David Rowley Discussion: https://postgr.es/m/CAApHDvrBztXP3yx=NKNmo3xwFAFhEdyPnvrDg3=M0RhDs+4vYw@mail.gmail.com Reviewed-by: Andres Freund, Victor Yegorov
Diffstat (limited to 'src/include/access/tupmacs.h')
-rw-r--r--src/include/access/tupmacs.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index 58b3a58cfd0..622adfa5f86 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -14,6 +14,7 @@
#ifndef TUPMACS_H
#define TUPMACS_H
+#include "access/tupdesc.h"
#include "catalog/pg_type_d.h" /* for TYPALIGN macros */
@@ -30,8 +31,8 @@ att_isnull(int ATT, const bits8 *BITS)
#ifndef FRONTEND
/*
- * Given a Form_pg_attribute and a pointer into a tuple's data area,
- * return the correct value or pointer.
+ * Given a Form_pg_attribute or CompactAttribute and a pointer into a tuple's
+ * data area, return the correct value or pointer.
*
* We return a Datum value in all cases. If the attribute has "byval" false,
* we return the same pointer into the tuple data area that we're passed.