磨砺技术珠矶,践行数据之道,追求卓越价值

回到上一级页面:PostgreSQL内部结构与源代码研究索引页    回到顶级页面:PostgreSQL索引页

作者 高健@博客园  luckyjackgao@gmail.com

首先要了解 vacuum 与  vacuum all的区别:

vacuum 就是进行扫除,找到那些旧的“死”数据,把它们所知的行标记为可用状态。但是它不进行空间合并。

vacuum full,就是除了 vacuum,还进行空间合并,因此它需要lock table。

而 autovacuum,可以理解为 定时自动进行  vacuum 。

对于有大量update 的表,vacuum full是没有必要的,因为它的空间还会再次增长,所以vacuum就足够了。

所以说: standard VACUUMs often enough to avoid needing VACUUM FULL

并且:    The autovacuum daemon attempts to work this way, and in fact will never issue VACUUM FULL.

http://www.postgresql.org/docs/9.2/static/routine-vacuuming.html#AUTOVACUUM

The usual goal of routine vacuuming is to do standard VACUUMs often enough to avoid needing VACUUM FULL. The autovacuum daemon attempts to work this way, and in fact will never issue VACUUM FULL. In this approach, the idea is not to keep tables at their minimum size, but to maintain steady-state usage of disk space: each table occupies space equivalent to its minimum size plus however much space gets used up between vacuumings. Although VACUUM FULL can be used to shrink a table back to its minimum size and return the disk space to the operating system, there is not much point in this if the table will just grow again in the future. Thus, moderately-frequent standard VACUUM runs are a better approach than infrequent VACUUM FULL runs for maintaining heavily-updated tables.

因此:

Moderately-frequent standard VACUUM runs are a better approach than infrequent VACUUM FULL runs for maintaining heavily-updated tables.

关于 VACUUM FULL:

VACUUM FULL requires exclusive lock on the table it is working on, and therefore cannot be done in parallel with other use of the table. Generally, therefore, administrators should strive to use standard VACUUM and avoid VACUUM FULL.

VACUUM FULL要写新表、新文件的:

The standard form of VACUUM removes dead row versions in tables and indexes and marks the space available for future reuse. However, it will not return the space to the operating system, except 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. 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.

对于 大量 update/delete 的表,普通的vacuum可能是不合适的,此时需要VACUUM FULL:

(有点前后矛盾,可能是指数据变更量更大的情况)

Plain VACUUM may not be satisfactory when a table contains large numbers of dead row versions as a result of massive update or delete activity. If you have such a table and you need to reclaim the excess disk space it occupies, you will need to use VACUUM FULL, or alternatively CLUSTER or one of the table-rewriting variants of ALTER TABLE. These commands rewrite an entire new copy of the table and build new indexes for it. All these options require exclusive lock.

作者 高健@博客园  luckyjackgao@gmail.com

回到上一级页面:PostgreSQL内部结构与源代码研究索引页    回到顶级页面:PostgreSQL索引页

磨砺技术珠矶,践行数据之道,追求卓越价值

PostgreSQL的autovacuum 与 vacuum full的更多相关文章

  1. [转载]再谈PostgreSQL的膨胀和vacuum机制及最佳实践

    本文转载自 www.postgres.cn 下的文章: 再谈PostgreSQL的膨胀和vacuum机制及最佳实践http://www.postgres.cn/news/viewone/1/390 还 ...

  2. 【转】postgreSQL​之autovacuum性能问题分析(一)

    最近笔者在项目中遇到postgreSQL的性能问题,所以计划在公众号里写一个系列文章去追踪记录这些问题以及分析过程或解决方法. 本文主要是关于postgreSQL的autovacuum的问题.可能很多 ...

  3. PostgreSQL配置文件--AUTOVACUUM参数

    8 AUTOVACUUM参数 AUTOVACUUM PARAMETERS 8.1 autovacuum 字符型 默认: autovacuum = on Enable autovacuum subpro ...

  4. PostgreSQL Autovacuum和vacuum

    1 基础知识 重点: 如果您的数据库运行了很久,并且从来没有打开过autovacuum,那么请在打开autovacuum之前全库手动运行vacuum analyze(可能要非常久的时间)完全禁用aut ...

  5. 【转】postgreSQL​之autovacuum性能问题分析(二)

    如上篇文章提到,如果出现了autovacuum的问题,那么这可能是个悲伤的故事.怎么解决? 笔者觉得可以从如下几个方面着手去考虑解决问题,可以避免一些坑.1) 持续观察,是不是autovacuum问题 ...

  6. PostgreSQL VACUUM 之深入浅出 (一)

    前言 VACUUM 是 PostgreSQL MVCC (Multiversion concurrency control) 实现的核心机制之一,是 PostgreSQL 正常运行的重要保证.本文将通 ...

  7. PostgreSQL VACUUM 之深入浅出 (四)

    VACUUM 参数优化 上面已经介绍过了以下设置表级 AUTOVACUUM 相关参数和 autovacuum_max_workers: ALTER TABLE pgbench_accounts SET ...

  8. postgresql vacuum操作

    postgresql vacuum操作 PostgreSQL数据库管理工作中,定期vacuum是一个重要的工作.vacuum的效果: 1.1释放,再利用 更新/删除的行所占据的磁盘空间. 1.2更新P ...

  9. PostgreSQL事务实现

    事务简介 事务管理器:有限状态机 日志管理器 CLOG:事务的执行结果 XLOG:undo/redo日志 锁管理器:实现并发控制,读阶段采用MVCC,写阶段采用锁控制实现不同的隔离级别 Postgre ...

随机推荐

  1. [微信] 客服接口调用的时候返回 40003 Invalid OpenID

    首先确认收件人在24小时内主动向公众号发过消息.该消息的 FromUserId 即是客服消息的 touser 参数的 OpenId 2017-05-19 更新:可以使用UTF-8了 string ur ...

  2. python_循环(迭代)

    #for 和 while #for用来迭代处理,什么叫迭代?你就当没看到这个词,for是把一堆玩意做一个一个加工用的,比如吃一袋花生,得一个一个剥吧,就是这意思 a = 'abcde' #每个字母当做 ...

  3. c基础_笔记_1

    定义变量 int i; 也可以 int i,num; 赋值,c必须先定义变量再赋值 num = 0; 循环for for(i=1; i<=0; i++) { printf("%d \n ...

  4. python升级 (2.6升级到3.5)

    在引用模块pandas时竟然提示不支持2.6, 果断升级,在网上找了很多博客,觉得这个比较清楚(https://blog.csdn.net/my_bai/article/details/7289602 ...

  5. Python学习---ModelForm拾遗180325

    ModelForm适用于前台验证和后台直接操作数据库的前后台未做分离,可以一次执行验证和保存数据的场景. 注意:  1.  ModelForm里面没有删除方法,需要手动删除内容 2. ModelFor ...

  6. Python学习---Form拾遗180322

    Form操作之错误信息操作 1. 用户发送请求过来 2. for 循环对字段进行正则表达式的验证  fields.clean(value) 3. 自定义clean_字段() 进行名字段值正确性的校验 ...

  7. 什么是 .live()

    很多开发者都知道jQuery的.live()方法,他们大部分知道这个函数做什么,但是并不知道是怎么实现的,所以用的并不那么舒适.而且他们却从未听过还有解除绑定的.live()事件的.die()方法.即 ...

  8. php操作redis的两个个小脚本

    redis这东西,查询起来没有mysql那么方便,只能自己写脚本了.下面是工作中写的两个小脚本 第一个脚本,查找有lottery|的键,将他们全部删除|打印出来 <?php $redis = n ...

  9. 【译文】InnoDB 的不同的SQL如何加锁

    http://dev.mysql.com/doc/refman/5.6/en/innodb-locks-set.html 前置:检索如果用不到索引,会扫描全表,并根据策略加锁.所以,这就是我们合理建立 ...

  10. css-table属性运用

    最近在工作中遇到了一些不常用的布局,很多使用 CSS table 属性,并结合 ::before,::after 伪元素完成了,使得 HTML 的结构相对更简单,更具有语义性.当 HTML 结构越清晰 ...