A.16.1. | 哪些类型的操作会修改二级索引并导致更改缓冲?What types of operations modify secondary indexes and result in
change buffering? |
| INSERT、UPDATE 和 DELETE 操作可能会修改二级索引。如果受影响的索引页不在缓冲池中,修改可以缓存在更改缓冲中。INSERT, UPDATE, and
DELETE operations can modify secondary
indexes. If an affected index page is not in the buffer pool,
the changes can be buffered in the change buffer.
|
A.16.2. | InnoDB 更改缓冲的好处是什么?What is the benefit of the InnoDB change
buffer?
|
| 当辅助索引页不在缓冲池中时,对辅助索引的更改进行缓冲,可以避免立即从磁盘读取受影响索引页所需的昂贵随机访问 I/O 操作。缓冲的更改可以稍后以批量方式应用,当页面通过其他读取操作被读入缓冲池时。Buffering secondary index changes when secondary index pages are
not in the buffer pool avoids expensive random access I/O
operations that would be required to immediately read in
affected index pages from disk. Buffered changes can be applied
later, in batches, as pages are read into the buffer pool by
other read operations. |
A.16.3. | 更改缓冲是否支持其他类型的索引?Does the change buffer support other types of indexes? |
| 不支持。更改缓冲只支持辅助索引。聚簇索引、全文索引和空间索引不支持。全文索引有其自己的缓存机制。No. The change buffer only supports secondary indexes. Clustered
indexes, full-text indexes, and spatial indexes are not
supported. Full-text indexes have their own caching mechanism. |
A.16.4. | InnoDB 为更改缓冲使用多少空间?How much space does InnoDB use for the change
buffer?
|
| 在 MySQL 5.6 引入 innodb_change_buffer_max_size 配置选项之前,系统表空间中磁盘上的更改缓冲区的最大大小是 InnoDB 缓冲池大小的 1/3。Prior to the introduction of the
innodb_change_buffer_max_size
configuration option in MySQL 5.6, the maximum size of the
on-disk change buffer in the system tablespace was 1/3 of the
InnoDB buffer pool size. 在 MySQL 5.6 及更高版本中,innodb_change_buffer_max_size 配置选项定义了更改缓冲区的最大大小,占总缓冲池大小的百分比。默认情况下,innodb_change_buffer_max_size 设置为 25。最大设置为 50。In MySQL 5.6 and later, the
innodb_change_buffer_max_size
configuration option defines the maximum size of the change
buffer as a percentage of the total buffer pool size. By
default,
innodb_change_buffer_max_size
is set to 25. The maximum setting is 50. InnoDB 如果操作会导致磁盘上的更改缓冲区超过定义的限制,则不会缓冲该操作。InnoDB does not buffer an operation if it
would cause the on-disk change buffer to exceed the defined
limit.
更改缓冲页面不需要在缓冲池中持久存在,并且可能会被 LRU 操作驱逐。Change buffer pages are not required to persist in the buffer
pool and may be evicted by LRU operations. |
A.16.5. | 我如何确定更改缓冲区的当前大小?How do I determine the current size of the change buffer? |
| 更改缓冲区的当前大小可以通过 SHOW ENGINE INNODB STATUS \G 查看,在 INSERT BUFFER AND ADAPTIVE HASH INDEX 章节下。例如:The current size of the change buffer is reported by
SHOW ENGINE INNODB STATUS \G, under the
INSERT BUFFER AND ADAPTIVE HASH INDEX
heading. For example: -------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
相关的数据点包括:Relevant data points include: size:更改缓冲区中使用的页面数。更改缓冲区大小等于 seg
size - (1 + free list len)。这里的 1
+ 值代表更改缓冲区头页面。size: The number of pages used within the
change buffer. Change buffer size is equal to seg
size - (1 + free list len). The 1
+ value represents the change buffer header page.
seg size:更改缓冲区的大小,以页为单位。seg size: The size of the change buffer,
in pages.
有关监控更改缓冲区状态的信息,请参见 第 17.5.2 节,“更改缓冲区”。For information about monitoring change buffer status, see
Section 17.5.2, “Change Buffer”. |
A.16.6. | 何时进行更改缓冲区合并?When does change buffer merging occur? |
| 当页面被读取到缓冲池中时,在读取完成后、页面可用之前,会合并缓冲的更改。When a page is read into the buffer pool, buffered changes
are merged upon completion of the read, before the page is
made available. 更改缓冲区合并作为后台任务执行。innodb_io_capacity 参数设置了 InnoDB 后台任务执行 I/O 活动(例如从更改缓冲区合并数据)的上限。Change buffer merging is performed as a background task. The
innodb_io_capacity
parameter sets an upper limit on the I/O activity performed
by InnoDB background tasks such as
merging data from the change buffer. 在崩溃恢复期间会执行更改缓冲区合并。更改从更改缓冲区(在系统表空间中)应用到辅助索引的叶子页,当索引页被读取到缓冲池中时。A change buffer merge is performed during crash recovery.
Changes are applied from the change buffer (in the system
tablespace) to leaf pages of secondary indexes as index
pages are read into the buffer pool. 更改缓冲区是完全持久的,即使系统崩溃也可以保留。重启后,更改缓冲区合并操作会作为正常操作的一部分继续进行。The change buffer is fully durable and can survive a system
crash. Upon restart, change buffer merge operations resume
as part of normal operations. 在使用 --innodb-fast-shutdown=0 进行缓慢服务器关闭时,可以强制对更改缓冲区进行完全合并。A full merge of the change buffer can be forced as part of a
slow server shutdown using
--innodb-fast-shutdown=0.
|
A.16.7. | 何时会刷新更改缓冲区?When is the change buffer flushed? |
| 更新的页面通过刷新机制刷新,该机制同样会刷新占用缓冲池的其他页面。Updated pages are flushed by the same flushing mechanism that
flushes the other pages that occupy the buffer pool. |
A.16.8. | 何时应使用更改缓冲区?When should the change buffer be used? |
| 变更缓冲区是一个旨在减少对二级索引的随机 I/O 的功能,当索引变得越来越大且不再适合 InnoDB 缓冲池时特别有用。通常,当整个数据集无法装入缓冲池、存在大量修改二级索引页的 DML 活动,或存在许多经常被 DML 操作修改的二级索引时,应该使用变更缓冲区。The change buffer is a feature designed to reduce random I/O to
secondary indexes as indexes grow larger and no longer fit in
the InnoDB buffer pool. Generally, the change
buffer should be used when the entire data set does not fit into
the buffer pool, when there is substantial DML activity that
modifies secondary index pages, or when there are lots of
secondary indexes that are regularly changed by DML activity. |
A.16.9. | 什么时候不应该使用变更缓冲区?When should the change buffer not be used? |
| 如果整个数据集可以容纳在InnoDB缓冲池中,如果您只有相对较少的二级索引,或者如果您使用的是固态存储(随机读取速度几乎与顺序读取一样快),您可以考虑禁用更改缓冲区。在进行配置更改之前,建议您使用代表性工作负载进行测试,以确定禁用更改缓冲区是否带来任何好处。You might consider disabling the change buffer if the entire
data set fits within the InnoDB buffer pool,
if you have relatively few secondary indexes, or if you are
using solid-state storage, where random reads are about as fast
as sequential reads. Before making configuration changes, it is
recommended that you run tests using a representative workload
to determine if disabling the change buffer provides any
benefit. |
A.16.10. | 我可以在哪里找到关于更改缓冲区的更多信息?Where can I find additional information about the change buffer? |
| 请参见第 17.5.2 节,“更改缓冲区”。See Section 17.5.2, “Change Buffer”. |