先看3个参数:
autovacuum_freeze_max_age           | 500000
vacuum_freeze_min_age               | 10
vacuum_freeze_table_age             | 100000
首先如果pg_class表age(relfrozenxid)大于autovacuum_freeze_max_age,那么数据库系统会自动做vacuum,回收年龄
没有达到500000之前,不做vacuum
hank=>  select oid::regclass,age(relfrozenxid) from pg_class where relname='hank' and relowner=16392;
 oid  |  age  
------+--------
 hank | 495471
(1 row)
达到后,立即做vacuum
hank=>  select oid::regclass,age(relfrozenxid) from pg_class where relname='hank' and relowner=16392;
 oid  |  age  
------+--------
 hank | 504559
(1 row)
可见日志:
2017-08-07 17:23:44.193 CST,,,4774,,5988319d.12a6,2,,2017-08-07 17:23:41 CST,3/5308,0,LOG,00000,"automatic vacuum of table ""hank.hank.hank"": index scans: 0
pages: 0 removed, 1596 remain, 0 skipped due to pins, 0 skipped frozen
tuples: 0 removed, 307278 remain, 0 are dead but not yet removable
buffer usage: 3204 hits, 1 misses, 1278 dirtied
avg read rate: 0.003 MB/s, avg write rate: 3.386 MB/s
system usage: CPU 0.00s/0.05u sec elapsed 2.94 sec",,,,,,,,,""
vacuum后age回到vacuum_freeze_min_age所设置的值,注意这里做的是vacuum,不是vacuum freeze,如果手工做vacuum freeze,age(relfrozenxid)会降到0
hank=>  select oid::regclass,age(relfrozenxid) from pg_class where relname='hank' and relowner=16392;
 oid  | age
------+-----
 hank |  10
(1 row)
这里手工freeze后,回到0开始计数
hank=> vacuum freeze hank;
VACUUM
hank=>  select oid::regclass,age(relfrozenxid) from pg_class where relname='hank' and relowner=16392;
 oid  | age
------+-----
 hank |   0
(1 row)
另外对vacuum_freeze_table_age参数说明一下:
普通的vacuum由visibility map决定表的那些page需要被扫描,正常情况下,会跳过没有dead row的page,即使这些page有旧的xid值,所以,正常vacuum并不冻结表中所有行的xid,vacuum_freeze_table_age控制什么时候需要扫描全表,并冻结所有行的xid,如果事物数大于(vacuum_freeze_table_age-vacuum_freeze_min_age),那么就扫描所有可见的,没有冻结的page,如果vacuum_freeze_table_age设置为0,那么每次都会强制扫描所有page。

原文:https://blog.csdn.net/dazuiba008/article/details/77159027

最新文章

  1. http 缓存相关学习
  2. iPad Pro分辨率
  3. Linux查看redis进程
  4. java简单日历
  5. 洛谷P3128 [USACO15DEC]最大流Max Flow [倍增LCA]
  6. Java——表格
  7. strcpy 和 strnpy 区别
  8. HDU1429+bfs+状态压缩
  9. 20160322 javaweb 学习笔记--response验证码实现
  10. 火狐的bug
  11. .net版Git Server --- bonobo
  12. MPEG-DASH on IIS Practice in Action
  13. Android Studio的两种模式及签名配置
  14. C#:将.csv格式文件转换成.xlsx格式文件
  15. 在python后台如何将客户端提交的form表单数据提取出来?
  16. BZOJ3531 树剖 + 动态开点线段树
  17. ASP.NET MVC Web API 学习笔记---Web API概述及程序示例
  18. centos7 安装oracle11g
  19. Luogu P2403 [SDOI2010]所驼门王的宝藏
  20. BugPhobia团队篇章:团队管理与Github源代码管理说明

热门文章

  1. io.lettuce.core.protocol.ConnectionWatchdog - Reconnecting, last destination was ***
  2. sqlserver exists 与 in 的区别
  3. CentOS 6.9安装配置nmon
  4. 怎样安装ipython
  5. Windows终端命令行工具Cmder
  6. C#ModBus Tcp 报文解析
  7. java利用反射打印出类的结构
  8. 对比centos7的systemctl和其他service+chkconfig
  9. c# 属性说明
  10. 数组中的filter,every,some,find,findIndex