This article brings you an introduction to the usage of MySQL's MVCC. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
MVCC (Multi-version Concurrency Control)
Function: In many cases, locking operations can be avoided and overhead reduced.
MVCC under InnoDB
is implemented by saving two hidden columns behind each row of records, the row's creation time and the row's expiration time (deletion time). The time here refers to the system version number. Every time a new thing is started, the system version number will increase automatically. The system version number at the start of the transaction will be used as the version number of the transaction, which is used to compare with the version number of each row of records queried.
Specific operations of MVCC under the REPEATABLE READ isolation level
SELECT
InnoDB only searches for data rows whose version is earlier than the current transaction version (row system Version number
line is either undefined or greater than the current thing version number. This ensures that the rows read by the transaction are not deleted before the transaction starts.
Only records that meet the above two conditions can return the query results.
INSERT
InnoDB saves the current system version number as the row version number for each newly inserted row.
UPDATE
InnoDB inserts a new row of records, saves the current system version number as the row version number, and saves the current system version number to the original row as the row deletion identifier. .
DELETE
InnoDB saves the current system version number as the deletion identification for each deleted row.
This article has ended here. For more other exciting content, you can pay attention to theMySQL Tutorial Videocolumn on the PHP Chinese website!
The above is the detailed content of Introduction to the usage of MySQL's MVCC. For more information, please follow other related articles on the PHP Chinese website!