table inheritance versus column compression and storage settings

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: table inheritance versus column compression and storage settings
Date: 2023-12-04 10:52:43
Message-ID: 24656cec-d6ef-4d15-8b5b-e8dfc9c833a7@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found the way that MergeAttributes() handles column compression and
storage settings very weird.

For example, I don't understand the purpose of this error:

create table t1 (a int, b text compression pglz);

create table t1a (b text compression lz4) inherits (t1);
...
ERROR: 42804: column "b" has a compression method conflict
DETAIL: pglz versus lz4

or this:

create table t2 (a int, b text compression lz4);

create table t12 () inherits (t1, t2);
...
ERROR: column "b" has a compression method conflict
DETAIL: pglz versus lz4

And we can't override it in the child, per the first example.

But this works:

create table t1a (a int, b text compression lz4);
alter table t1a inherit t1;

Also, you can change the settings in the child using ALTER TABLE ... SET
COMPRESSION (which is also how pg_dump will represent the above
constructions), so the restrictions at CREATE TABLE time don't seem to
make much sense.

Looking at the code, I suspect these rules were just sort of
copy-and-pasted from the nearby rules for types and collations. The
latter are needed so that a table with inheritance children can present
a logically consistent view of the data. But compression and storage
are physical properties that are not logically visible, so every table
in an inheritance hierarchy can have their own setting.

I think the rules should be approximately like this (both for
compression and storage):

- A newly created child inherits the settings from the parent.
- A newly created child can override the settings.
- Attaching a child changes nothing.
- When inheriting from multiple parents with different settings, an
explicit setting in the child is required.

Thoughts?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-12-04 11:00:49 Re: pg_upgrade and logical replication
Previous Message John Naylor 2023-12-04 10:52:19 Commitfest 2023-11 is now closed