Commit edad08ba authored by Robert Haas's avatar Robert Haas

Update ALTER TABLE docs to mention using VACUUM FULL for rewrites.

Remove the claim that ALTER TABLE .. SET DATA TYPE is the fastest way of
rewriting a table, since it no longer is.

Noah Misch and Robert Haas, based on a suggestion from Tom Lane.
parent 6f59a5e5
...@@ -403,9 +403,9 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable> ...@@ -403,9 +403,9 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
for details on the available parameters. Note that the table contents for details on the available parameters. Note that the table contents
will not be modified immediately by this command; depending on the will not be modified immediately by this command; depending on the
parameter you might need to rewrite the table to get the desired effects. parameter you might need to rewrite the table to get the desired effects.
That can be done with <xref linkend="SQL-CLUSTER"> That can be done with <link linkend="SQL-VACUUM">VACUUM
or one of the forms of <command>ALTER FULL</>, <xref linkend="SQL-CLUSTER"> or one of the forms
TABLE</> that forces a table rewrite. of <command>ALTER TABLE</> that forces a table rewrite.
</para> </para>
<note> <note>
...@@ -777,18 +777,11 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable> ...@@ -777,18 +777,11 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
</para> </para>
<para> <para>
The fact that <literal>SET DATA TYPE</> requires rewriting the whole table To force an immediate rewrite of the table, you can use
is sometimes an advantage, because the rewriting process eliminates <link linkend="SQL-VACUUM">VACUUM FULL</>, <xref linkend="SQL-CLUSTER">
any dead space in the table. For example, to reclaim the space occupied or one of the forms of ALTER TABLE that forces a rewrite, such as
by a dropped column immediately, the fastest way is: SET DATA TYPE. This results in no semantically-visible change in the
<programlisting> table, but gets rid of no-longer-useful data.
ALTER TABLE table ALTER COLUMN anycol TYPE anytype;
</programlisting>
where <literal>anycol</> is any remaining table column and
<literal>anytype</> is the same type that column already has.
This results in no semantically-visible change in the table,
but the command forces rewriting, which gets rid of no-longer-useful
data.
</para> </para>
<para> <para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment