change buffer是在其他数据库中没有的一个概念,说白了就是一块系统表空间分配的空间,针对的对象是辅助索引的叶子节点(为什么不是主键索引?因为主键索引是聚集索引,在磁盘上的排列是有序的,磁盘的顺序IO的性能很高,而随机IO的性能却很低)。当辅助索引的值有更新时,将这些更新先缓存起来,当有其他应用对相同的页做更新操作后,对该页进行整合,最后将整合后的值一起更新到磁盘文件中,减少了磁盘的I/O. change buffer是由InnoDB的系统表空间分配的,虽然叫buffer,但和double write buffer一样,都是表空间的空间,可以和其他数据页一样缓存在buffer pool中。
以下是change buffer相关文档的翻译,来自官方文档。
14.9.4 Configuring InnoDB Change Buffering
When INSERT, UPDATE, and DELETE operations are performed on a table, the values of indexed columns (particularly the values of secondary keys) are often in an unsorted order, requiring substantial I/O to bring secondary indexes up to date. InnoDB has a change buffer that caches changes to secondary index entries when the relevant page is not in the buffer pool, thus avoiding expensive I/O operations by not immediately reading in the page from disk. The buffered changes are merged when the page is loaded to the buffer pool, and the updated page is later flushed to disk. The InnoDB main thread merges buffered changes when the server is nearly idle, and during a slow shutdown.
当对表进行增删改操作的时候,由于索引列(尤其是复制索引列)的值总是无序的,更新辅助索引往往需要大量的随机I/O操作。InnoDB的change buffer会存放一些辅助索引条目,当有DML操作对辅助索引修改时,会先对这些索引页进行整合,之后一块刷新到磁盘上。InnoDB的主线程会在系统I/O空闲时或关机时整合这些索引页。
Because it can result in fewer disk reads and writes, the change buffer feature is most valuable for workloads that are I/O-bound, for example applications with a high volume of DML operations such as bulk inserts.
因为change buffer可以减少磁盘的读写,在有大量读写绑定的操作上会更体现它的价值,比如说对于批量插入操作的应用来说。
However, the change buffer occupies a part of the buffer pool, reducing the memory available to cache data pages. If the working set almost fits in the buffer pool, or if your tables have relatively few secondary indexes, it may be useful to disable change buffering. If the working set fits entirely within the buffer, change buffering does not impose extra overhead, because it only applies to pages that are not in the buffer pool.
然而,change buffer会占用buffer pool的内存空间,这样就会减少数据页在内存中的缓存。因此对于有辅助索引相关的表操作的时候,change buffer可能会有用,对于工作集都在缓冲池中的操作,change buffer就不会起作用,因为它只应用于索引页不完全在内存中的情况。
You can control the extent to which InnoDB performs change buffering using the innodb_change_buffering configuration parameter. You can enable or disable buffering for inserts, delete operations (when index records are initially marked for deletion) and purge operations (when index records are physically deleted). An update operation is a combination of an insert and a delete. In MySQL 5.5 and higher, the default innodb_change_buffering value is changed from inserts to all.
可以使用参数innodb_change_buffering来对是否使用change buffer来进行控制,5.5及以上的版本中默认值是all.
Permitted innodb_change_buffering values include:
该参数的参数值包含一下:
all

The default value: buffer inserts, delete-marking operations, and purges.

none

Do not buffer any operations.

inserts

Buffer insert operations.

deletes

Buffer delete-marking operations.

changes

Buffer both inserts and delete-marking operations.

purges

Buffer the physical deletion operations that happen in the background.

You can set the innodb_change_buffering parameter in the MySQL option file (my.cnf or my.ini) or change it dynamically with the SET GLOBAL command, which requires the SUPER privilege. Changing the setting affects the buffering of new operations; the merging of existing buffered entries is not affected.
innodb_change_buffering参数的值可以在配置文件(my.cnf or my.ini)中设置,或者具有SUPER权限的用户使用SET GLOBAL命令动态的修改,修改只对以后的操作生效。

可以通过以下命令来监控change buffer。
mysql> SHOW ENGINE INNODB STATUS\G;

-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
merged operations:
insert 0, delete mark 0, delete 0
discarded operations:
insert 0, delete mark 0, delete 0
Hash table size 276707, node heap has 1 buffer(s)
15.81 hash searches/s, 46.33 non-hash searches/s

seg size 指segment总的分配大小,以页为单位;
free list 指空闲数据页;
size 指已经合并数据页数量。

mysql小特性:change buffer的更多相关文章

  1. Mysql InnoDB三大特性-- change buffer

    Mysql InnoDB三大特性-- change buffer

  2. MySQL · 引擎特性 · InnoDB Buffer Pool

    前言 用户对数据库的最基本要求就是能高效的读取和存储数据,但是读写数据都涉及到与低速的设备交互,为了弥补两者之间的速度差异,所有数据库都有缓存池,用来管理相应的数据页,提高数据库的效率,当然也因为引入 ...

  3. InnoDB关键特性之change buffer

    一.关于IOT:索引组织表 表在存储的时候按照主键排序进行存储,同时在主键上建立一棵树,这样就形成了一个索引组织表,一个表的存储方式以索引的方式来组织存储的. 所以,MySQL表一定要加上主键,通过主 ...

  4. MySQL -- Innodb中的change buffer

    change buffer是一种特殊的数据结构,当要修改的辅助索引页不在buffer pool中时,用来cache对辅助索引页的修改.对辅助索引页的操作可能是insert.update和delete操 ...

  5. MySql 缓冲池(buffer pool) 和 写缓存(change buffer) 转

    应用系统分层架构,为了加速数据访问,会把最常访问的数据,放在缓存(cache)里,避免每次都去访问数据库. 操作系统,会有缓冲池(buffer pool)机制,避免每次访问磁盘,以加速数据的访问. M ...

  6. 全网最清楚的:MySQL的insert buffer和change buffer 串讲

    目录 一.前言 二.问题引入 2.1.聚簇索引 2.2.普通索引 三.change buffer存在的意义 四.再看change buffer 五.change buffer 的限制 六.change ...

  7. my36_InnoDB关键特性之change buffer

    一.关于IOT:索引组织表 表在存储的时候按照主键排序进行存储,同时在主键上建立一棵树,这样就形成了一个索引组织表,一个表的存储方式以索引的方式来组织存储的. 所以,MySQL表一定要加上主键,通过主 ...

  8. MySQL:change buffer

    1. 概念 Innodb维护了一个缓存区域叫做Buffer Pool,用来缓存数据和索引在内存中.其大小通过参数 innodb_buffer_pool_size 控制: change buffer 是 ...

  9. mysql 原理 ~ change buffer

    一 简介:今天咱们来聊聊mysql的change buffer二 详细说明   1 +-change Buffer和数据页一样,也是物理页的一个组成部分,数据结构也是一颗B+树,这棵B+树放在共享表空 ...

随机推荐

  1. 解决Non-resolvable parent POM: Could not find artifact 出现的问题

    在编译spring boot 多模块项目的时候,往往出现 Non-resolvable parent POM: Could not find artifact 后面跟一串其它信息,网上大部分解决方案是 ...

  2. ubuntu 18 设置语言环境

    1. 查看语言环境 ubuntu系统中,存在两个系统变量:$LANG和$LANGUAGE 分别控制语言环境和地区,这两个变量是从/etc/default/locale中读取的: 方法一: echo $ ...

  3. mvn 打包命令

    mvn install & package:package是把jar打到本项目的target下,而install时把target下的jar安装到本地仓库,供其他项目使用. mvn clean ...

  4. tcp三次握手和四次挥手(2)

      背景描述 通过上一篇中网络模型中的IP层的介绍,我们知道网络层,可以实现两个主机之间的通信.但是这并不具体,因为,真正进行通信的实体是在主机中的进程,是一个主机中的一个进程与另外一个主机中的一个进 ...

  5. jquery mobile开发中常见的问题(转载)

    1页面缩放显示问题 问题描述: 页面似乎被缩小了,屏幕太宽了. 处理方法: 在head标签内加入: <meta name="viewport" content="w ...

  6. SQL Server ->> 与SQL Server服务配置相关的DMV

    1) sys.dm_server_services这个DMV可以告诉我们与当前版本的SQL Server相关的服务的启动状态和最后一次启动的时间,诸如这样的信息. SELECT * FROM sys. ...

  7. 关于“为什么不加friend就会提示参数过多”

    #include <iostream> using namespace std; class Complex { double real, imag; public: Complex(do ...

  8. windows7 端口查看以及杀死进程释放端口

    1.调出命令窗口:开始---->运行---->cmd,或者是window+R组合键 2.输入命令:netstat -ano,列出所有端口的情况.在列表中我们观察被占用的端口,比如是4300 ...

  9. C++ int与string的相互转换(含源码实现)

    一.int转换成string Ⅰ.to_string函数 c++11标准增加了全局函数std::to_string: string to_string (int val); string to_str ...

  10. windows时间同步脚本

    #!/usr/bin/env python# -*- coding:UTF-8 -*-# 脚本用于windows时间同步,设置window计划任务每五分钟执行一次 import timeimport ...