When INSERT
s are done to a table, often
the values of indexed columns (particularly the values of
secondary keys) are not in sorted order. This means that the
inserts of such values into secondary B-tree indexes is
“random”, and this can cause excessive i/o if the
entire index does not fit in memory. InnoDB has an insert
buffer that caches changes to secondary index entries when the
relevant page is not in the buffer pool, thus avoiding I/O
operations by not reading in the page from the disk. The buffered
changes are written into a special insert buffer tree and are
subsequently merged when the page is loaded to the buffer pool.
The InnoDB main thread merges buffered changes when the server
is nearly idle.
Usually, this process will result in fewer disk reads and writes, especially during bulk inserts. However, the insert buffer tree will occupy a part of the buffer pool. If the working set almost fits in the buffer pool, it may be useful to disable insert buffering. If the working set entirely fits in the buffer pool, insert buffering will not be used anyway, because the index would exist in memory.
Beginning with InnoDB Plugin 1.0.3, you can control
whether InnoDB performs insert buffering with the system
configuration parameter innodb_change_buffering
. The allowed
values of innodb_change_buffering
are none
(do not buffer any operations) and inserts
(buffer insert operations, the default). You can set the value of
this 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 already buffered entries is not affected.
This is the User’s Guide for InnoDB Plugin 1.0.6 for MySQL 5.1, generated on March 4, 2010 (rev 673:680M).