15.4.2 Change Buffer(变更缓冲)

 
The change buffer is a special data structure that caches changes to secondary index pages when affected pages are not in the buffer pool. The buffered changes, which may result from INSERT, UPDATE, or DELETE operations (DML), are merged later when the pages are loaded into the buffer pool by other read operations.
 
变更缓冲是一个特殊的数据结构,当目标页不在缓冲池中时,变更缓冲负责缓存对二级索引页的变更。被缓冲的变更内容可能是INSERT,UPDATE,或DELETE操作(DML)的结果。在下一次读操作时这些页会被载入缓冲池,之后变更缓冲中的内容将被合并。
 
Unlike clustered indexes, secondary indexes are usually non-unique, and inserts into secondary indexes happen in a relatively random order. Similarly, deletes and updates may affect secondary index pages that are not adjacently located in an index tree. Merging cached changes at a later time, when affected pages are read into the buffer pool by other operations, avoids substantial random access I/O that would be required to read-in secondary index pages from disk.
 
与聚簇索引不同,二级索引通常不唯一,并且插入二级索引的顺序比较随机。删除和更新对二级索引页产生类似的影响,这是因为目标页在索引树上的位置并不相邻。被影响的页会通过某些操作被读入缓冲池,这个过程需要从磁盘上读取二级索引页,所以合并已缓存变更内容的操作的会在此过程之后执行,以避免大量的随机I/O。
 
Periodically, the purge operation that runs when the system is mostly idle, or during a slow shutdown, writes the updated index pages to disk. The purge operation can write disk blocks for a series of index values more efficiently than if each value were written to disk immediately.
 
清理操作发生在系统基本空闲或缓慢关闭期间,它会周期性的把更新过的索引页写入磁盘。清理操作可以把索引值批量写入磁盘,这样比把单个值直接写入磁盘更有效率。
 
Change buffer merging may take several hours when there are numerous secondary indexes to update and many affected rows. During this time, disk I/O is increased, which can cause a significant slowdown for disk-bound queries. Change buffer merging may also continue to occur after a transaction is committed. In fact, change buffer merging may continue to occur after a server shutdown and restart (see Section 15.21.2, “Forcing InnoDB Recovery” for more information).
 
当有许多二级索引要更新并且同时影响多行记录时,变更缓冲合并可能需要耗费数个小时。在此期间,磁盘I/O不断增加,这样会造成磁盘读取性能显著下降。变更缓冲合并可能会在事务提交后继续发生。事实上,变更缓冲合并也可能在服务关闭和重启后继续发生(更多信息,请参考15.21.2, “强制InnoDB恢复”)。
 
In memory, the change buffer occupies part of the InnoDB buffer pool. On disk, the change buffer is part of the system tablespace, so that index changes remain buffered across database restarts.
 
在内存中,变更缓冲占用了InnoDB缓冲池的部分空间。在磁盘上,变更缓冲是系统表空间的一部分,这使得索引变更即使在系统重启后仍然处于缓冲状态。
 
The type of data cached in the change buffer is governed by the innodb_change_buffering configuration option. For more information, see Section 15.6.5, “Configuring InnoDB Change Buffering”. You can also configure the maximum change buffer size. For more information, see Section 15.6.5.1, “Configuring the Change Buffer Maximum Size”.
 
变更缓冲中缓存的数据类型通过innodb_change_buffering配置项进行管理。更多信息,请看15.6.5,“配置InnoDB变更缓冲”。你也可以配置变更缓冲大小的上限。更多信息,请看15.6.5.1,“配置变更缓冲大小上限”。
 
Monitoring the Change Buffer(监控变更缓冲)
 
The following options are available for change buffer monitoring:
 
以下选项可用于变更缓冲监控:
 
  • InnoDB Standard Monitor output includes status information for the change buffer. To view monitor data, issue the SHOW ENGINE INNODB STATUS command.
 
在InnoDB标准监视器中会输出变更缓冲的状态信息。要查看监控数据,就输入“SHOW ENGINE INNODB STATUS ”命令。
mysql> SHOW ENGINE INNODB STATUS\G
Change buffer status information is located under the INSERT BUFFER AND ADAPTIVE HASH INDEX heading and appears similar to the following:
 
变更缓冲的状态信息位于“INSERT BUFFER AND ADAPTIVE HASH INDEX”标题栏的下方,如下所示。
-------------------------------------
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 4425293, used cells 32, node heap has 1 buffer(s)

13577.57 hash searches/s, 202.47 non-hash searches/s
For more information, see Section 15.17.3, “InnoDB Standard Monitor and Lock Monitor Output”.
 
更多信息,请参考15.17.3,“InnoDB标准监视器与锁定监视器输出”。
 
  • The INFORMATION_SCHEMA.INNODB_METRICS table provides most of the data points found in InnoDB Standard Monitor output, plus other data points. To view change buffer metrics and a description of each, issue the following query:
 
INFORMATION_SCHEMA.INNODB_METRICS表提供了在InnoDB标准监视器中输出的大部分数据点,以及其他数据点。要看变更缓冲的指标及其描述,输入以下查询:
mysql> SELECT NAME, COMMENT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME LIKE '%ibuf%'\G
For INNODB_METRICS table usage information, see Section 15.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”.
 
如何使用INNODB_METRICS表的信息,请参考15.15.6,“InnoDB INFORMATION_SCHEMA指标表 Table”。
 
  • The INFORMATION_SCHEMA.INNODB_BUFFER_PAGE table provides metadata about each page in the buffer pool, including change buffer index and change buffer bitmap pages. Change buffer pages are identified by PAGE_TYPE. IBUF_INDEX is the page type for change buffer
    index pages, and IBUF_BITMAP is the page type for change buffer bitmap pages.
 
INFORMATION_SCHEMA.INNODB_BUFFER_PAGE表提供缓冲池中每一页的元数据,包括变更缓冲索引页和变更缓冲位图页。变更缓冲页是通过一些标记来识别的,PAGE_TYPE. IBUF_INDEX表示页类型是变更缓冲索引页,IBUF_BITMAP表示页类型是变更缓冲位图页。
Warning
Querying the INNODB_BUFFER_PAGE table
can introduce significant performance overhead. To avoid impacting performance, reproduce the issue you want to investigate on a test instance and run your queries on the test instance.
For example, you can query the INNODB_BUFFER_PAGE table to determine the approximate number of IBUF_INDEX and IBUF_BITMAP pages as a percentage of total buffer pool pages.
 
例如,你可以查询INNODB_BUFFER_PAGE,通过计算占总缓冲池页的百分比来确认IBUF_INDEX页和IBUF_BITMAP页的大致数量。
SELECT
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE PAGE_TYPE LIKE 'IBUF%'
) AS change_buffer_pages,
(
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
) AS total_pages,
(
SELECT ((change_buffer_pages/total_pages)*100)
) AS change_buffer_page_percentage;
+---------------------+-------------+-------------------------------+
| change_buffer_pages | total_pages | change_buffer_page_percentage |
+---------------------+-------------+-------------------------------+
|                  25 |        8192 |                        0.3052 |
+---------------------+-------------+-------------------------------+
 
For information about other data provided by the INNODB_BUFFER_PAGE table, seeSection 23.31.1, “The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table”. For related usage information, see Section 15.15.5, “InnoDB INFORMATION_SCHEMA Buffer
Pool Tables”.
 
更多关于INNODB_BUFFER_PAGE表所提供的其他数据的信息,请参考23.31.1,“INFORMATION_SCHEMA INNODB_BUFFER_PAGE表”。相关用法,请参考 15.15.5,“InnoDB INFORMATION_SCHEMA缓冲池表”。
 
  • Performance Schema provides change buffer mutex wait instrumentation for advanced performance monitoring. To view change buffer instrumentation, issue the following query:
 
Performance Schema提供对变更缓冲互斥等待的检测信息以增强对于性能的监控能力。要看性能缓冲检测信息,输入以下查询:
mysql> SELECT * FROM performance_schema.setup_instruments
WHERE NAME LIKE '%wait/synch/mutex/innodb/ibuf%';
+-------------------------------------------------------+---------+-------+
| NAME                                                  | ENABLED | TIMED |
+-------------------------------------------------------+---------+-------+
| wait/synch/mutex/innodb/ibuf_bitmap_mutex             | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_mutex                    | YES     | YES   |
| wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex | YES     | YES   |

+-------------------------------------------------------+---------+-------+
For information about monitoring InnoDB mutex waits, see Section 15.16.2, “Monitoring InnoDB Mutex Waits Using Performance Schema”.
 
更多关于监控InnoDB互斥等待的信息,请参考15.16.2,“使用Performance Schema监控InnoDB互斥等待”。

MySQL 5.7 Reference Manual】15.4.2 Change Buffer(变更缓冲)的更多相关文章

  1. 【MySQL 5.7 Reference Manual】15.4.2 Change Buffer(变更缓冲)

    15.4.2 Change Buffer(变更缓冲)   The change buffer is a special data structure that caches changes to se ...

  2. MySQL :: MySQL 5.0 Reference Manual :: 14.4 The MEMORY (HEAP) Storage Engine

    MySQL :: MySQL 5.0 Reference Manual :: 14.4 The MEMORY (HEAP) Storage Engine The MEMORY (HEAP) Stora ...

  3. MySQL 5.7 Reference Manual :: 4.5.4 mysqldump & mysql — Database Backup & Restore Program

    MySQL :: MySQL 5.7 Reference Manual :: 4.5.4 mysqldump — A Database Backup Programhttps://dev.mysql. ...

  4. MySQL :: MySQL 8.0 Reference Manual :: B.6.4.3 Problems with NULL Values https://dev.mysql.com/doc/refman/8.0/en/problems-with-null.html

    MySQL :: MySQL 8.0 Reference Manual :: B.6.4.3 Problems with NULL Values https://dev.mysql.com/doc/r ...

  5. [MySQL Reference Manual]15. 其他存储引擎

    15. 其他存储引擎 15. 其他存储引擎 15.1 设置存储引擎 15.2 MyISAM存储引擎 15.2.1 MyISAM启动选项 15.2.2 Key的空间要求 15.2.3 MyISAM表存储 ...

  6. [MySQL Reference Manual]14 InnoDB存储引擎

    14 InnoDB存储引擎 14 InnoDB存储引擎 14.1 InnoDB说明 14.1.1 InnoDB作为默认存储引擎 14.1.1.1 存储引擎的趋势 14.1.1.2 InnoDB变成默认 ...

  7. MySQL 5.6 Reference Manual-14.6 InnoDB Table Management

    14.6 InnoDB Table Management 14.6.1 Creating InnoDB Tables 14.6.2 Moving or Copying InnoDB Tables to ...

  8. OpenCASCADE6.8.0 Reference Manual Serach Problem

    OpenCASCADE6.8.0 Reference Manual Serach Problem eryar@163.com 1. Problem 有网友反映OpenCASCADE6.8.0的Refe ...

  9. ePass1000 Full ActiveX Control Reference Manual Version 2.0

    ePass1000 Full ActiveX Control Reference Manual Version 2.0 Error Code Value Return Status Descripti ...

随机推荐

  1. django项目的生产环境部署,利用nginx+uwsgi

    1.坏境准备 centos6.5 django项目 python坏境(python3.6,) 所需的各种模块(django,uwsgi,sqlite3)具体看坏境 我的测试django项目的数据库用的 ...

  2. Boosting和Bagging的异同

    二者都是集成学习算法,都是将多个弱学习器组合成强学习器的方法. 1.Bagging (主要关注降低方差) Bagging即套袋法,其算法过程如下: A)从原始样本集中抽取训练集.每轮从原始样本集中使用 ...

  3. windwos文档格式转换成unix格式

    在工作学习中我们避免不了需要将一些脚本和命令记录在笔记里面,我使用的是有道云笔记,每当我将上次记录在有道云的脚本复制出来进行使用的时候,总会报一些奇怪的错误,要么是包含换行符,要么就是格式不对,但是我 ...

  4. Linux下C语言的调试--转

    调试是每个程序员都会面临的问题. 如何提高程序员的调试效率, 更好更快地定位程序中的问题从而加快程序开发的进度, 是大家共同面对的问题. 可能Windows用户顺口就会说出:用VC呗 :-) , 它提 ...

  5. UOJ #357. 【JOI2017春季合宿】Sparklers

    Description 小S和小M去看花火大会. 一共有 n 个人按顺序排成一排,每个人手上有一个仅能被点燃一次的烟花.最开始时第 K 个人手上的烟花是点燃的. 烟花最多能燃烧 T 时间.每当两个人的 ...

  6. hadoop学习笔记(四):HDFS

    一.HDFS体系结构 1 HDFS假设条件 数据流访问 大数据集 简单相关模型 移动计算比移动数据便宜 多种软硬件平台中的可移植性 2 HDFS的设计目标 非常巨大的分布式文件系统 运行于普通硬件上 ...

  7. Linux下的MongoDB安装&启动&关闭

    一.下载安装包 下载地址 二.解压安装包 $ tar -zxvf mongodb-linux-x86_64-3.0.6.tgz 三.复制到指定的目录下 $ mv mongodb-linux-x86_6 ...

  8. 如何在HTML 5中拖动光标图标?

    window.app = { dragging: false, config: { canDrag: false, cursorOffsetX: null, cursorOffsetY: null } ...

  9. Xcode DEBUG宏定义,debug和release模式的选择

    设置DEBUG, 使用宏定义: #if DEBUG NSLog(@"debug model"); #else //执行release模式的代码 #endif

  10. ActiveMQ Could not connect to broker URL

    javax.jms.JMSException: Could not connect to broker URL: http://localhost:8161/. Reason: java.io.IOE ...