diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-05-23 12:12:09 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-05-23 12:12:09 -0400 |
commit | f5024d8d7b04de2f5f4742ab433cc38160354861 (patch) | |
tree | 7cbd6c5ebc78fb3a1b221b8d28193f6ddc5efb90 /src/backend/access/common | |
parent | bc2a389efb3b52d259cefd53c16cfa00742116f2 (diff) | |
download | postgresql-f5024d8d7b04de2f5f4742ab433cc38160354861.tar.gz postgresql-f5024d8d7b04de2f5f4742ab433cc38160354861.zip |
Re-order pg_attribute columns to eliminate some padding space.
Now that attcompression is just a char, there's a lot of wasted
padding space after it. Move it into the group of char-wide
columns to save a net of 4 bytes per pg_attribute entry. While
we're at it, swap the order of attstorage and attalign to make for
a more logical grouping of these columns.
Also re-order actions in related code to match the new field ordering.
This patch also fixes one outright bug: equalTupleDescs() failed to
compare attcompression. That could, for example, cause relcache
reload to fail to adopt a new value following a change.
Michael Paquier and Tom Lane, per a gripe from Andres Freund.
Discussion: https://postgr.es/m/20210517204803.iyk5wwvwgtjcmc5w@alap3.anarazel.de
Diffstat (limited to 'src/backend/access/common')
-rw-r--r-- | src/backend/access/common/tupdesc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index ffb275afbee..affbc509bdc 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -424,7 +424,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) * general it seems safer to check them always. * * attcacheoff must NOT be checked since it's possibly not set in both - * copies. + * copies. We also intentionally ignore atthasmissing, since that's + * not very relevant in tupdescs, which lack the attmissingval field. */ if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0) return false; @@ -440,9 +441,11 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) return false; if (attr1->attbyval != attr2->attbyval) return false; + if (attr1->attalign != attr2->attalign) + return false; if (attr1->attstorage != attr2->attstorage) return false; - if (attr1->attalign != attr2->attalign) + if (attr1->attcompression != attr2->attcompression) return false; if (attr1->attnotnull != attr2->attnotnull) return false; @@ -460,7 +463,7 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) return false; if (attr1->attcollation != attr2->attcollation) return false; - /* attacl, attoptions and attfdwoptions are not even present... */ + /* variable-length fields are not even present... */ } if (tupdesc1->constr != NULL) @@ -639,12 +642,11 @@ TupleDescInitEntry(TupleDesc desc, att->attbyval = typeForm->typbyval; att->attalign = typeForm->typalign; att->attstorage = typeForm->typstorage; - att->attcollation = typeForm->typcollation; - if (IsStorageCompressible(typeForm->typstorage)) att->attcompression = GetDefaultToastCompression(); else att->attcompression = InvalidCompressionMethod; + att->attcollation = typeForm->typcollation; ReleaseSysCache(tuple); } @@ -709,6 +711,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc, att->attbyval = false; att->attalign = TYPALIGN_INT; att->attstorage = TYPSTORAGE_EXTENDED; + att->attcompression = GetDefaultToastCompression(); att->attcollation = DEFAULT_COLLATION_OID; break; @@ -717,6 +720,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc, att->attbyval = true; att->attalign = TYPALIGN_CHAR; att->attstorage = TYPSTORAGE_PLAIN; + att->attcompression = InvalidCompressionMethod; att->attcollation = InvalidOid; break; @@ -725,6 +729,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc, att->attbyval = true; att->attalign = TYPALIGN_INT; att->attstorage = TYPSTORAGE_PLAIN; + att->attcompression = InvalidCompressionMethod; att->attcollation = InvalidOid; break; @@ -733,6 +738,7 @@ TupleDescInitBuiltinEntry(TupleDesc desc, att->attbyval = FLOAT8PASSBYVAL; att->attalign = TYPALIGN_DOUBLE; att->attstorage = TYPSTORAGE_PLAIN; + att->attcompression = InvalidCompressionMethod; att->attcollation = InvalidOid; break; |