删除列后 VACUUM FULL 会缩小行宽吗?
Does VACUUM FULL shrink row width after deleting a column?
根据文档,在 postgresql 中删除行后,它们仍处于死状态,因此需要定期清理以回收此 space。从表中删除列时,这是否也适用于行宽,或者 space 是否永远分配?
答案是是 - space 被回收了。
来自 documentation 关于 VACUUM
(大胆强调我的):
it writes a new copy of the table and doesn't release the old copy until the operation is complete
并且从关于 ALTER TABLE
的页面注释:
To force immediate reclamation of space occupied by a dropped column, you can execute one of the forms of ALTER TABLE that performs a rewrite of the whole table. This results in reconstructing each row with the dropped column replaced by a null value.
还有一个:
depending on the parameter you might need to rewrite the table to get the desired effects. That can be done with VACUUM FULL, CLUSTER or one of the forms of ALTER TABLE that forces a table rewrite.
根据文档,在 postgresql 中删除行后,它们仍处于死状态,因此需要定期清理以回收此 space。从表中删除列时,这是否也适用于行宽,或者 space 是否永远分配?
答案是是 - space 被回收了。
来自 documentation 关于 VACUUM
(大胆强调我的):
it writes a new copy of the table and doesn't release the old copy until the operation is complete
并且从关于 ALTER TABLE
的页面注释:
To force immediate reclamation of space occupied by a dropped column, you can execute one of the forms of ALTER TABLE that performs a rewrite of the whole table. This results in reconstructing each row with the dropped column replaced by a null value.
还有一个:
depending on the parameter you might need to rewrite the table to get the desired effects. That can be done with VACUUM FULL, CLUSTER or one of the forms of ALTER TABLE that forces a table rewrite.