Save a few bytes in pg_attribute
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 28 Mar 2023 07:58:14 +0000 (09:58 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 28 Mar 2023 08:05:56 +0000 (10:05 +0200)
commit90189eefc1e11822794e3386d9bafafd3ba3a6e8
treea39c438171cc52a6750c366a193050016db742d7
parent637dce2254245321283ade9db1b7cc8d1f8cf308
Save a few bytes in pg_attribute

Change the columns attndims, attstattarget, and attinhcount from int32
to int16, and reorder a bit.  This saves some space (currently 4
bytes) in pg_attribute and tuple descriptors, which translates into
small performance benefits and/or room for new columns in pg_attribute
needed by future features.

attndims and attinhcount are never realistically used with values
larger than int16.  Just to be sure, add some overflow checks.
attstattarget is currently limited explicitly to 10000.

For consistency, pg_constraint.coninhcount is also changed like
attinhcount.

Discussion: https://www.postgresql.org/message-id/flat/d07ffc2b-e0e8-77f7-38fb-be921dff71af%40enterprisedb.com
doc/src/sgml/catalogs.sgml
src/backend/access/common/tupdesc.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/pg_constraint.c
src/backend/commands/tablecmds.c
src/include/catalog/catversion.h
src/include/catalog/pg_attribute.h
src/include/catalog/pg_constraint.h