mirror of
https://github.com/postgres/postgres.git
synced 2025-12-22 17:42:17 +03:00
Rethink definition of pg_attribute.attcompression.
Redefine '\0' (InvalidCompressionMethod) as meaning "if we need to compress, use the current setting of default_toast_compression". This allows '\0' to be a suitable default choice regardless of datatype, greatly simplifying code paths that initialize tupledescs and the like. It seems like a more user-friendly approach as well, because now the default compression choice doesn't migrate into table definitions, meaning that changing default_toast_compression is usually sufficient to flip an installation's behavior; one needn't tediously issue per-column ALTER SET COMPRESSION commands. Along the way, fix a few minor bugs and documentation issues with the per-column-compression feature. Adopt more robust APIs for SetIndexStorageProperties and GetAttributeCompression. Bump catversion because typical contents of attcompression will now be different. We could get away without doing that, but it seems better to ensure v14 installations all agree on this. (We already forced initdb for beta2, anyway.) Discussion: https://postgr.es/m/626613.1621787110@sss.pgh.pa.us
This commit is contained in:
@@ -104,7 +104,6 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
|
||||
GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( <replaceable>sequence_options</replaceable> ) ] |
|
||||
UNIQUE <replaceable class="parameter">index_parameters</replaceable> |
|
||||
PRIMARY KEY <replaceable class="parameter">index_parameters</replaceable> |
|
||||
COMPRESSION <replaceable class="parameter">compression_method</replaceable> |
|
||||
REFERENCES <replaceable class="parameter">reftable</replaceable> [ ( <replaceable class="parameter">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
|
||||
[ ON DELETE <replaceable class="parameter">referential_action</replaceable> ] [ ON UPDATE <replaceable class="parameter">referential_action</replaceable> ] }
|
||||
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
|
||||
@@ -391,24 +390,27 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
This sets the compression method to be used for data inserted into a column.
|
||||
|
||||
This form sets the compression method for a column, determining how
|
||||
values inserted in future will be compressed (if the storage mode
|
||||
permits compression at all).
|
||||
This does not cause the table to be rewritten, so existing data may still
|
||||
be compressed with other compression methods. If the table is rewritten with
|
||||
<command>VACUUM FULL</command> or <command>CLUSTER</command>, or restored
|
||||
with <application>pg_restore</application>, then all tuples are rewritten
|
||||
with the configured compression methods.
|
||||
|
||||
Also, note that when data is inserted from another relation (for example,
|
||||
by <command>INSERT ... SELECT</command>), tuples from the source data are
|
||||
not necessarily detoasted, and any previously compressed data is retained
|
||||
with its existing compression method, rather than recompressing with the
|
||||
compression methods of the target columns.
|
||||
|
||||
with <application>pg_restore</application>, then all values are rewritten
|
||||
with the configured compression method.
|
||||
However, when data is inserted from another relation (for example,
|
||||
by <command>INSERT ... SELECT</command>), values from the source table are
|
||||
not necessarily detoasted, so any previously compressed data may retain
|
||||
its existing compression method, rather than being recompressed with the
|
||||
compression method of the target column.
|
||||
The supported compression
|
||||
methods are <literal>pglz</literal> and <literal>lz4</literal>.
|
||||
<literal>lz4</literal> is available only if <literal>--with-lz4</literal>
|
||||
was used when building <productname>PostgreSQL</productname>.
|
||||
(<literal>lz4</literal> is available only if <option>--with-lz4</option>
|
||||
was used when building <productname>PostgreSQL</productname>.) In
|
||||
addition, <replaceable class="parameter">compression_method</replaceable>
|
||||
can be <literal>default</literal>, which selects the default behavior of
|
||||
consulting the <xref linkend="guc-default-toast-compression"/> setting
|
||||
at the time of data insertion to determine the method to use.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -22,7 +22,7 @@ PostgreSQL documentation
|
||||
<refsynopsisdiv>
|
||||
<synopsis>
|
||||
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name</replaceable> ( [
|
||||
{ <replaceable class="parameter">column_name</replaceable> <replaceable class="parameter">data_type</replaceable> [ COLLATE <replaceable>collation</replaceable> ] [ COMPRESSION <replaceable>compression_method</replaceable> ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
|
||||
{ <replaceable class="parameter">column_name</replaceable> <replaceable class="parameter">data_type</replaceable> [ COMPRESSION <replaceable>compression_method</replaceable> ] [ COLLATE <replaceable>collation</replaceable> ] [ <replaceable class="parameter">column_constraint</replaceable> [ ... ] ]
|
||||
| <replaceable>table_constraint</replaceable>
|
||||
| LIKE <replaceable>source_table</replaceable> [ <replaceable>like_option</replaceable> ... ] }
|
||||
[, ... ]
|
||||
@@ -293,17 +293,22 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
|
||||
<listitem>
|
||||
<para>
|
||||
The <literal>COMPRESSION</literal> clause sets the compression method
|
||||
for a column. Compression is supported only for variable-width data
|
||||
types, and is used only for columns whose storage type is main or
|
||||
extended. (See <xref linkend="sql-altertable"/> for information on
|
||||
column storage types.) Setting this property for a partitioned table
|
||||
for the column. Compression is supported only for variable-width data
|
||||
types, and is used only when the column's storage mode
|
||||
is <literal>main</literal> or <literal>extended</literal>.
|
||||
(See <xref linkend="sql-altertable"/> for information on
|
||||
column storage modes.) Setting this property for a partitioned table
|
||||
has no direct effect, because such tables have no storage of their own,
|
||||
but the configured value is inherited by newly-created partitions.
|
||||
but the configured value will be inherited by newly-created partitions.
|
||||
The supported compression methods are <literal>pglz</literal> and
|
||||
<literal>lz4</literal>. <literal>lz4</literal> is available only if
|
||||
<literal>--with-lz4</literal> was used when building
|
||||
<productname>PostgreSQL</productname>. The default
|
||||
is <literal>pglz</literal>.
|
||||
<literal>lz4</literal>. (<literal>lz4</literal> is available only if
|
||||
<option>--with-lz4</option> was used when building
|
||||
<productname>PostgreSQL</productname>.) In addition,
|
||||
<replaceable class="parameter">compression_method</replaceable>
|
||||
can be <literal>default</literal> to explicitly specify the default
|
||||
behavior, which is to consult the
|
||||
<xref linkend="guc-default-toast-compression"/> setting at the time of
|
||||
data insertion to determine the method to use.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -975,8 +975,8 @@ PostgreSQL documentation
|
||||
<para>
|
||||
Do not output commands to set <acronym>TOAST</acronym> compression
|
||||
methods.
|
||||
With this option, all objects will be created using whichever
|
||||
compression method is the default during restore.
|
||||
With this option, all columns will be restored with the default
|
||||
compression setting.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -464,12 +464,12 @@ PostgreSQL documentation
|
||||
<para>
|
||||
Do not output commands to set <acronym>TOAST</acronym> compression
|
||||
methods.
|
||||
With this option, all objects will be created using whichever
|
||||
compression method is the default during restore.
|
||||
With this option, all columns will be restored with the default
|
||||
compression setting.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--no-unlogged-table-data</option></term>
|
||||
<listitem>
|
||||
|
||||
Reference in New Issue
Block a user