Update: Heikki’s slides are here!

Heikki Linnakangas gave a presentation this past Sunday at FOSDEM about the improved free space map (FSM), which tracks unused space inside the database, and new visibility map, a bitmap which will indicate which data pages can be skipped during a partial VACUUM. This performance enhancement will affect all users of the upcoming 8.4 software release. You can see what the new FSM implementation looked like back in October fromdepesz’s blog.

Despite Heikki’s modest claim during the talk that the performance tests were inconclusive, the consensus among Postgres contributors is that this feature will result a substantial improvement in the performance of VACUUM for tables that are large, but have few UPDATEs.

The new free space map and Visibility map (in 8.4) and autovacuum (enabled by default starting in version 8.2) are huge administrative usability improvements to version 8 of Postgres. Prior to version 8.1, VACUUM had to be scheduled outside of database system. Autovacuum has been part of the core Postgres distribution for over two years, and is tunable via several global configuration parameters.

The visibility map enables partial VACUUMs — meaning that VACUUM no longer has to examine every tuple to update the FSM. The new FSM implementation eliminates two configuration parameters, effectively automating a formerly manual configuration process.

The new FSM is stored on disk in seperate files inside of $PGDATA/base/, and is cached in shared_buffers. The result is that the max_fsm_* configuration parameters are no longer in 8.4 — Postgres is able to track and adjust this data structure without user intervention.

A few critical features of the new FSM are:

* Now a binary tree structure
* Constructed using 1 byte per heap page
* The top level shows the maximum amount of contiguous space available
* The data structure is auto-repairing and can be reconstructed from the bottom

Previously, every time that VACUUM was run, the free space map had to be reconstructed from scratch. Now, individual nodes in the map may be updated (aka “retail” updates).

Visibility map is a bitmap of heap pages which tracks which tuples on pages are visible to transactions, and therefore not available for VACUUMing.

Previously, when VACUUM ran, it *had* to look at every tuple in a table, because there was no information about which pages may not have been updated since the last VACUUM. With the visibility map, VACUUM will now be able to perform partial scans of table data, skipping pages which are marked as fully visible. Partial scans means fewer I/O operations for VACUUM, and happier database administrators.

注:老文章了,看到了学习一下。

1、以前在执行vacuum时,fsm都会重构,现在则会单独节点的更新(此处应指8.4版本)。

2、之前看到一些max_fsm_*的参数,原来在8.4之后就没有了。

3、有了vm文件,可以方便vacuum清理时不必扫描对其他事务都可见的页。因为vacuum只清理已删除的,但又没有访问的情况。该tuple经过update或delete后,但或仍有事务没有提交,仍可见旧版本,此时是无法清理的。可以参考pg的MVCC或HOT了解的更细一些。

4、根据篇头的文档,vacuum仍然需要扫描全表,是因为:

Whole-table scanning VACUUMs are still needed to avoid transaction ID wraparound。

参考:

http://www.chesnok.com/daily/2009/02/10/fsm-visibility-map-and-new-vacuum-awesomeness/

https://wiki.postgresql.org/images/8/81/FSM_and_Visibility_Map.pdf

FSM, VISIBILITY MAP AND VACUUM的更多相关文章

  1. PostgreSQL Autovacuum和vacuum

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

  2. Postgresql vacuum freeze相关参数

    先看3个参数:autovacuum_freeze_max_age           | 500000vacuum_freeze_min_age               | 10vacuum_fr ...

  3. GaussDB(DWS)磁盘维护:vacuum full执行慢怎么办?

    摘要:在数据库中用于维护数据库磁盘空间的工具是VACUUM,其重要的作用是删除那些已经标示为删除的数据并释放空间. vacuum的功能 回收空间 数据库总是不断地在执行删除,更新等操作.良好的空间管理 ...

  4. Go fsm

    package fsm import ( "log" ) type EvtIf interface { GetEvtType() string } type Action inte ...

  5. postgresql常见命令及操作

    pgsql已经更新到beta11了,不同版本的服务器启动或相关命令.配置可能会有不同,所以得根据pg版本进行操作.下面记录一些工作中常用到的一些操作,主要包括服务启动.备份/恢复数据.数据目录迁移.常 ...

  6. PostgreSQL 数据目录结构

    根目录介绍 data ├── base # use to store database file(SELECT oid, datname FROM pg_database;) ├── global # ...

  7. 为什么Index Only Scan却还需要访问表

    在实际SQL优化工作中,我们经常会发现SQL 执行计划明明是 "Index Only Scan",但执行计划后面却有 "Heap Fetches: x" ,也就 ...

  8. create tablespace 与 heap_insert 函数

    先说 heap_insert 函数: /* * heap_insert - insert tuple into a heap * * The new tuple is stamped with cur ...

  9. 对PostgreSQL xmin的深入学习

    当PostgreSQL需要insert 一条记录的时候,它会把记录头放入xmin,xmax等字段. xmin的值,就是当前的Transaction的TransactionId.这是为了满足MVCC的需 ...

随机推荐

  1. 2016 - 1 - 22 HTTP(一)

    一:通过URL找到服务器   1. URL的概念: 1.1 URL全称Uniform Resource Locatior 统一资源定位符 1.2 通过一个URL就可以找到互联网上的唯一的资源. 1.3 ...

  2. C#基础知识学习

    C#基础知识整理 学习地址:http://blog.csdn.net/column/details/csarp.html

  3. HDU3930 (原根)

    给定方程 X^A = B (mol C)  ,求 在[0,C) 中所有的解 , 并且C为质数. 设 rt 为 C 的原根 , 则 X = rt^x  (这里相当于求 A^x =B (mol C) 用大 ...

  4. BZOJ2661 连连看 (费用流)

    把所有点拆成两个,将符合条件的两个点x,y连上边,流量为1,费用为-(x+y). 做一遍最小费用最大流,最后ans div 2即可. Program bzoj2661; ; ..] of longin ...

  5. url重写技术

    URL 重写是截取传入 Web 请求并自动将请求重定向到其他 URL 的过程.比如浏览器发来请求 hostname/101.aspx ,服务器自动将这个请求中定向为http://hostname/li ...

  6. iOS开发环境C语言基础 运算符和表达式

    1 年龄判断程序 1.1 问题 本案例需要使用交互的方式判断年龄的范围:用户从控制台输入一个年龄,由程序判断该年龄是否在18~50岁之间.程序交互过程如图-1所示: 图-1 1.2 步骤 实现此案例需 ...

  7. I.MX6 SHT20 Linux 驱动移植

    /*********************************************************************** * I.MX6 SHT20 Linux 驱动移植 * ...

  8. I.MX6 mfgtool2-android-mx6q-sabresd-emmc.vbs hacking

    /******************************************************************** * I.MX6 mfgtool2-android-mx6q- ...

  9. 如果两个对象具有相同的哈希码,但是不相等的,它们可以在HashMap中同时存在吗?

    如果两个对象具有相同的哈希码,但是不相等的,它们可以在HashMap中同时存在吗? ----答案是 可以 原因: 在hashmap中,由于key是不可以重复的,他在判断key是不是重复的时候就判断了h ...

  10. python中如何判断某个变量是否存在

    方法一:try...except... 方法二: locals().has_key('var') var变量存在返回True, 不存在返回False 方法三:'var' in dir() 同样返回Tr ...