pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Introduce CompactAttribute array in TupleDesc
Date: Tue, 03 Dec 2024 03:51:55 +0000
Message-ID: <E1tIJx5-000qa3-44@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d28dff3f6cd6a7562fb2c211ac0fb74a33ffd032

Modified Files
--------------
src/backend/access/common/heaptuple.c  | 53 ++++++++++---------
src/backend/access/common/indextuple.c | 26 ++++-----
src/backend/access/common/tupdesc.c    | 70 ++++++++++++++++++++----
src/backend/access/spgist/spgutils.c   |  4 +-
src/backend/catalog/index.c            |  2 +
src/backend/commands/tablecmds.c       |  4 ++
src/backend/executor/execTuples.c      |  4 +-
src/backend/utils/cache/relcache.c     | 21 +++++---
src/backend/utils/cache/typcache.c     | 13 +++++
src/include/access/htup_details.h      |  4 +-
src/include/access/itup.h              | 10 ++--
src/include/access/tupdesc.h           | 97 ++++++++++++++++++++++++++++++++--
src/include/access/tupmacs.h           |  5 +-
src/tools/pgindent/typedefs.list       |  1 +
14 files changed, 246 insertions(+), 68 deletions(-)



view thread (5+ messages)  latest in thread

Message-ID: <E1tIJx5-000qa3-44@gemulon.postgresql.org>
Permalink:  ../E1tIJx5-000qa3-44@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tIJx5-000qa3-44@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Introduce CompactAttribute array in TupleDesc
  In-Reply-To: <E1tIJx5-000qa3-44@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox