Skip to content

Commit edad08b

Browse files
committed
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.
1 parent 6f59a5e commit edad08b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

doc/src/sgml/ref/alter_table.sgml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
403403
for details on the available parameters. Note that the table contents
404404
will not be modified immediately by this command; depending on the
405405
parameter you might need to rewrite the table to get the desired effects.
406-
That can be done with <xref linkend="SQL-CLUSTER">
407-
or one of the forms of <command>ALTER
408-
TABLE</> that forces a table rewrite.
406+
That can be done with <link linkend="SQL-VACUUM">VACUUM
407+
FULL</>, <xref linkend="SQL-CLUSTER"> or one of the forms
408+
of <command>ALTER TABLE</> that forces a table rewrite.
409409
</para>
410410

411411
<note>
@@ -777,18 +777,11 @@ ALTER TABLE <replaceable class="PARAMETER">name</replaceable>
777777
</para>
778778

779779
<para>
780-
The fact that <literal>SET DATA TYPE</> requires rewriting the whole table
781-
is sometimes an advantage, because the rewriting process eliminates
782-
any dead space in the table. For example, to reclaim the space occupied
783-
by a dropped column immediately, the fastest way is:
784-
<programlisting>
785-
ALTER TABLE table ALTER COLUMN anycol TYPE anytype;
786-
</programlisting>
787-
where <literal>anycol</> is any remaining table column and
788-
<literal>anytype</> is the same type that column already has.
789-
This results in no semantically-visible change in the table,
790-
but the command forces rewriting, which gets rid of no-longer-useful
791-
data.
780+
To force an immediate rewrite of the table, you can use
781+
<link linkend="SQL-VACUUM">VACUUM FULL</>, <xref linkend="SQL-CLUSTER">
782+
or one of the forms of ALTER TABLE that forces a rewrite, such as
783+
SET DATA TYPE. This results in no semantically-visible change in the
784+
table, but gets rid of no-longer-useful data.
792785
</para>
793786

794787
<para>

0 commit comments

Comments
 (0)