Hi All,
We would like to support specifying column-level encoding directives during altering table from Heap/AO to AOCO. The main reason for this support is to make sure that the user can set both access method and column-level encodings w/ one command and (more importantly) one single table rewrite.
There are a few different approaches in doing this which I would like to ask your opinions about:
#1 Currently we have a
prototype adding a new syntax ENCODING(<options>,...) in an ATSETAM command, such as:
ALTER TABLE foo SET ACCESS METHOD ao_column ENCODING (COLUMN a ENCODING (compresstype=rle_type));
ALTER TABLE foo SET ACCESS METHOD ao_column ENCODING (DEFAULT COLUMN ENCODING (compresstype=rle_type));
— Similarly for the variation of ATSETAM:
ALTER TABLE foo SET WITH (appendonly=true, orientation=column) ENCODING (COLUMN a ENCODING (compresstype=rle_type));
#2 Put the encodings in the WITH clause, so one can do:
ALTER TABLE foo SET ACCESS METHOD ao_column WITH(COLUMN a ENCODIONG (compresstype=rle_type));
- Pros: seems like a quite natural usage. This was also my first thought.
- Cons: WITH clause is an existing syntax for specifying table-level options. Mixing them could lead to confusion, e.g., would the user then expect to call CREATE TABLE ... WITH (<table options>, <column encodings>) and we have to support that too?
#3 Just use the existing ALTER COLUMN … SET (…) syntax (functionality still WIP, but syntax is there). So one can do:
ALTER TABLE foo SET ACCESS METHOD ao_column, ALTER COLUMN a SET (compresstype=rle_type);
- Pros: no extra syntax so no user education on that :)
- Cons:
- Have to call two subcommands so there’s chance that users can forget about this usage and do two separate ALTER TABLE commands which will incur two table rewrite. So still some user education might be needed (though I imagine it’s easier to adopt than new syntax).
- This couldn’t specify the DEFAULT column encoding, which exists for CREATE TABLE (note that this is different than the table-level options, which would be overrided by the DEFAULT column encoding).
#4 Add an ALTER ENCODING subcommand so one can do:
ALTER TABLE foo SET ACCESS METHOD ao_column, ALTER ENCODING (COLUMN a ENCODIONG (compresstype=rle_type));
- Pros: can change DEFAULT encoding. It’s also a nice syntax to have if the user wants to change DEFAULT encoding for an existing AOCO table (though I’m not sure how useful it is).
- Cons: the bad side of both #1 and #3: this is a new syntax, AND we still need to calling two subcommands.
Thoughts?
Regards,
Huansong