- 论坛徽章:
- 0
|
最近在学习 PGSQL 的 document,和帖子上讨论的现象很接近,把学习心得贴上来 :wink:
PGSQL 为了实现在并发修改情况下的一致性读,当 UPDATE 或 DELETE 时,不会去修改或删除之前版本的数据。
多版本的数据会在数据文件上保留下来,直到用户执行 VACUUM 功能,才最终将 'DEAD ROW VERSIONS' 从数据表中清除。
VACUUM 可以删除过旧的行版本,提供空间给以后重用,但不会释放操作系统上的空间。
在特殊情况下会释放一小部分空间( in the special case where one or more pages at the end of a table become entirely free and an exclusive table lock can be easily obtained. )。
VACUUM 会实现操作系统上的空间缩减,实现方式是将表重新创建一个文件,然后将原表删除来实现的。这也就是说,需要在操作系统上有额外的空间,才能执行此操作。
In contrast, VACUUM FULL actively compacts tables by writing a complete new version of the table file with no dead space. This minimizes the size of the table, but can take a long time. It also requires extra disk space for the new copy of the table, until the operation completes.
http://www.postgresql.org/docs/9.1/static/maintenance.html
|
|