GNU Info

Info Node: (mysql.info)InnoDB Insert buffering

(mysql.info)InnoDB Insert buffering


Next: InnoDB Adaptive hash Prev: InnoDB physical structure Up: Table and index
Enter node , (file) or (file)node

Insert buffering
................

It is a common situation in a database application that the primary key
is a unique identifier and new rows are inserted in the ascending order
of the primary key. Thus the insertions to the clustered index do not
require random reads from a disk.

On the other hand, secondary indexes are usually non-unique and
insertions happen in a relatively random order into secondary indexes.
This would cause a lot of random disk i/o's without a special mechanism
used in InnoDB.

If an index record should be inserted to a non-unique secondary index,
InnoDB checks if the secondary index page is already in the buffer
pool. If that is the case, InnoDB will do the insertion directly to the
index page. But, if the index page is not found from the buffer pool,
InnoDB inserts the record to a special insert buffer structure.  The
insert buffer is kept so small that it entirely fits in the buffer
pool, and insertions can be made to it very fast.

The insert buffer is periodically merged to the secondary index trees
in the database. Often we can merge several insertions on the same page
in of the index tree, and hence save disk i/o's.  It has been measured
that the insert buffer can speed up insertions to a table up to 15
times.


automatically generated by info2www version 1.2.2.9