mysql小特性:change buffer
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的更多相关文章
- Mysql InnoDB三大特性-- change buffer
Mysql InnoDB三大特性-- change buffer
- MySQL · 引擎特性 · InnoDB Buffer Pool
前言 用户对数据库的最基本要求就是能高效的读取和存储数据,但是读写数据都涉及到与低速的设备交互,为了弥补两者之间的速度差异,所有数据库都有缓存池,用来管理相应的数据页,提高数据库的效率,当然也因为引入 ...
- InnoDB关键特性之change buffer
一.关于IOT:索引组织表 表在存储的时候按照主键排序进行存储,同时在主键上建立一棵树,这样就形成了一个索引组织表,一个表的存储方式以索引的方式来组织存储的. 所以,MySQL表一定要加上主键,通过主 ...
- MySQL -- Innodb中的change buffer
change buffer是一种特殊的数据结构,当要修改的辅助索引页不在buffer pool中时,用来cache对辅助索引页的修改.对辅助索引页的操作可能是insert.update和delete操 ...
- MySql 缓冲池(buffer pool) 和 写缓存(change buffer) 转
应用系统分层架构,为了加速数据访问,会把最常访问的数据,放在缓存(cache)里,避免每次都去访问数据库. 操作系统,会有缓冲池(buffer pool)机制,避免每次访问磁盘,以加速数据的访问. M ...
- 全网最清楚的:MySQL的insert buffer和change buffer 串讲
目录 一.前言 二.问题引入 2.1.聚簇索引 2.2.普通索引 三.change buffer存在的意义 四.再看change buffer 五.change buffer 的限制 六.change ...
- my36_InnoDB关键特性之change buffer
一.关于IOT:索引组织表 表在存储的时候按照主键排序进行存储,同时在主键上建立一棵树,这样就形成了一个索引组织表,一个表的存储方式以索引的方式来组织存储的. 所以,MySQL表一定要加上主键,通过主 ...
- MySQL:change buffer
1. 概念 Innodb维护了一个缓存区域叫做Buffer Pool,用来缓存数据和索引在内存中.其大小通过参数 innodb_buffer_pool_size 控制: change buffer 是 ...
- mysql 原理 ~ change buffer
一 简介:今天咱们来聊聊mysql的change buffer二 详细说明 1 +-change Buffer和数据页一样,也是物理页的一个组成部分,数据结构也是一颗B+树,这棵B+树放在共享表空 ...
随机推荐
- C#打印代码运行时间
使用以下方法可以准确的记录代码运行的耗时. System.Diagnostics.Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); / ...
- linux 设置git记住密码
linux下: 1.在~/下, touch创建文件 .git-credentials, 用vim编辑此文件,输入: https://{username}:{password}@github.com 注 ...
- java、C语言实现数组模拟栈
java: public class ArrayStack { private int[] data; private int top; private int size; public ArrayS ...
- Leetcode- Find Minimum in Rotated Sorted Array-ZZ
http://changhaz.wordpress.com/2014/10/15/leetcode-find-minimum-in-rotated-sorted-array/ Suppose a so ...
- 关于微信公账号H5 API 调用的坑 BUG
页面A已经配置过,如果是单页面跳转,则页面B可以共享当前的SDK配置(至少菜单是这样的) 刷新页面,原先的菜单仍然会保持原样,只是调用SDK已经失效了,需要重新配置,重新配置后,菜单仍然会保持原样(如 ...
- [问题记录]cocos2dx编译打包apk过程&问题记录
目录: 1. 入门 2. 编译 3. 问题 4. 总结 5. 参考 ------------------------------------------------------------------ ...
- l2tp over ipsec
搭建教程: 转自: https://segmentfault.com/a/1190000006125737 http://www.wangyuxiong.com/blog/ti-yan-qiang-w ...
- case选择语句
#!/bin/bash PS3="please select menu:" select i in "Apache" "Mysql&quo ...
- photo的复数是photos
以O结尾的单词变复数时,有生命的加es,无生命的加s. 如:photo,zoo,为无生命的,+s tomato,potato为有生命的,+es. 自己总结的,但到目前为止还没有遇到过例外的.记住这一个 ...
- 面试知识整理-Java基础
三大特征:封装,继承,多态 多态:简单的说就是用同样的对象引用调用同样的方法但是做了不同的事情. 抽象:抽象是将一类对象的共同特征总结出来构造类的过程 包装,可以讲基本类型当做对象来使用,抽象只关心对 ...