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. 操作Hadoop集群

    操作Hadoop集群 所有必要的配置完成后,将文件分发到所有机器上的HADOOP_CONF_DIR目录.这应该是所有机器上相同的目录. 一般来说,建议HDFS和YARN作为单独的用户运行.在大多数安装 ...

  2. maoaolianxi

    package dududu; public class maopao { public static void main(String[] args) { // TODO 自动生成的方法存根 ,,, ...

  3. Raspberry 安装vstudio

    Visual Studio Code微软公司推出的一款轻量级的Visual Studio风格的跨平台的IDE.当然,除了Windows,OSX,还能在树莓派上使用.目前树莓派上可用的IDE真不多,VS ...

  4. IIFE

    一.IIFE IIFE:immediately-invoked function expression,即时调用函数表达式. 如果一个函数,在定义的时候,就想直接调用它,就是一个IIFE. 函数执行方 ...

  5. 用opencv做的静态图片人脸识别

    这次给大家分享一个图像识别方面的小项目,主要功能是识别图像中的人脸并根据人脸在图片库找出同一个与它最相似的图片,也就是辨别不同的人. 环境:VS2013+opencv2.4.13 主要是算法:open ...

  6. ubuntu18.04安装谷歌浏览器

    sudo wget http://www.linuxidc.com/files/repo/google-chrome.list -P /etc/apt/sources.list.d/ wget -q ...

  7. Tomcat下JDBC连接样例

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  8. 体验SpringBoot

    体验SpringBoot 1.介绍 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开 ...

  9. 使用mysli防止sql注入

    自从 php5 推出 mysqli 后就开始不提倡使用 mysql_ 开头的接口了,现在使用 mysql_connet 通常调试的时候会报警告说这个不该用 mysqli 使用起来其实更简单 $url ...

  10. KDD 2013推荐系统论文

     LCARS: A Location-Content-Aware Recommender SystemAuthors: Hongzhi Yin, Peking University; Yizhou S ...