InnoDB Multi-Versioning
InnoDB is a multi-version storage engine. It keeps information about old versions of changed rows to support transactional features such as concurrency and rollback. This information is stored in the system tablespace or undo tablespaces in a data structure called a rollback segment. See Section 14.6.3.4, “Undo Tablespaces”. InnoDB uses the information in the rollback segment to perform the undo operations needed in a transaction rollback. It also uses the information to build earlier versions of a row for a consistent read. See Section 14.7.2.3, “Consistent Nonlocking Reads”.
Internally, InnoDB adds three fields to each row stored in the database:
-
A 6-byte
DB_TRX_IDfield indicates the transaction identifier for the last transaction that inserted or updated the row. Also, a deletion is treated internally as an update where a special bit in the row is set to mark it as deleted. -
A 7-byte
DB_ROLL_PTRfield called the roll pointer. The roll pointer points to an undo log record written to the rollback segment. If the row was updated, the undo log record contains the information necessary to rebuild the content of the row before it was updated. -
A 6-byte
DB_ROW_IDfield contains a row ID that increases monotonically as new rows are inserted. IfInnoDBgenerates a clustered index automatically, the index contains row ID values. Otherwise, theDB_ROW_IDcolumn does not appear in any index.
- 点赞
- 收藏
- 关注作者
评论(0)