mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
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
This commit is contained in:
@ -2640,8 +2640,8 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
def->constraints = NIL;
|
||||
def->location = -1;
|
||||
if (CompressionMethodIsValid(attribute->attcompression))
|
||||
def->compression = pstrdup(GetCompressionMethodName(
|
||||
attribute->attcompression));
|
||||
def->compression =
|
||||
pstrdup(GetCompressionMethodName(attribute->attcompression));
|
||||
else
|
||||
def->compression = NULL;
|
||||
inhSchema = lappend(inhSchema, def);
|
||||
@ -6596,12 +6596,19 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
attribute.atttypid = typeOid;
|
||||
attribute.attstattarget = (newattnum > 0) ? -1 : 0;
|
||||
attribute.attlen = tform->typlen;
|
||||
attribute.atttypmod = typmod;
|
||||
attribute.attnum = newattnum;
|
||||
attribute.attbyval = tform->typbyval;
|
||||
attribute.attndims = list_length(colDef->typeName->arrayBounds);
|
||||
attribute.attstorage = tform->typstorage;
|
||||
attribute.atttypmod = typmod;
|
||||
attribute.attbyval = tform->typbyval;
|
||||
attribute.attalign = tform->typalign;
|
||||
attribute.attstorage = tform->typstorage;
|
||||
/* do not set compression in views etc */
|
||||
if (rel->rd_rel->relkind == RELKIND_RELATION ||
|
||||
rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||
attribute.attcompression = GetAttributeCompression(&attribute,
|
||||
colDef->compression);
|
||||
else
|
||||
attribute.attcompression = InvalidCompressionMethod;
|
||||
attribute.attnotnull = colDef->is_not_null;
|
||||
attribute.atthasdef = false;
|
||||
attribute.atthasmissing = false;
|
||||
@ -6612,17 +6619,6 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
|
||||
attribute.attinhcount = colDef->inhcount;
|
||||
attribute.attcollation = collOid;
|
||||
|
||||
/*
|
||||
* lookup attribute's compression method and store it in the
|
||||
* attr->attcompression.
|
||||
*/
|
||||
if (rel->rd_rel->relkind == RELKIND_RELATION ||
|
||||
rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
|
||||
attribute.attcompression = GetAttributeCompression(&attribute,
|
||||
colDef->compression);
|
||||
else
|
||||
attribute.attcompression = InvalidCompressionMethod;
|
||||
|
||||
/* attribute.attacl is handled by InsertPgAttributeTuples() */
|
||||
|
||||
ReleaseSysCache(typeTuple);
|
||||
|
Reference in New Issue
Block a user