vacuumdb 清理空间问题
对于经常增删数据的表,做vacuumdb操作(不加f参数),能够重用空间。但这样做,就像物理硬盘一样,会不会也产生碎片呢? {:3_198:}没人回呀 应该不会,vacuum 会把已删除的挂在空闲链表上,下次分配时直接在空闲链表上找可用空间,具体细节不太清楚
vacuum 将空间返回给os thanks dudes :D) 这个基本上不是问题,每天定时运行一次会很轻松,碎片不会累积。 vacuum的时候,只是把不需要的数据打上标志,表示这些数据已经过期,可以覆盖这些数据了。而vacuum full就是彻底的回收数据所占用的空间,返还给OS。 vacuum analyse verbose 会,select relname,relkind,reltuples,relpages from pg_class where relkind='i' and relname like 'xxx'; 对比前后差距
Plain VACUUM (without FULL) simply reclaims space and makes it available for re-use. extra space is not returned to the operating system (in most cases); it’s just kept available for re-use within the same table. VACUUM FULL rewrites the entire contents of the table into a new disk file with no extra space, allowing unused space to be returned to the operating system. This form is much slower and requires an exclusive lock on each table while it is being processed.
页:
[1]