Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the MVCC of InnoDB in mysql realized?

Shulou Source: shulou.com Published: 2022-06-03 17:26:32 11月13日 Update

This article mainly introduces "what is the realization of the MVCC of InnoDB in mysql". In the daily operation, I believe that many people have doubts about what the MVCC of InnoDB in mysql is achieved through. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "what is the MVCC of InnoDB in mysql?" Next, please follow the editor to study!

1. InnoDB's MVCC is achieved by saving two hidden columns after each row of records.

These two columns, one holds the bank's transaction ID, and the other holds the bank's rollback pointer.

2. Every time you start a new transaction, a new transaction id is automatically added.

At the beginning of the transaction, the transaction id is placed in the transaction id affected by the current transaction. When querying, you need to compare the current transaction id with the transaction id for each row record.

Example

If you have a transaction that begins after update before delete and ends after delete, it looks like this:

Start transaction; / / if transaction id = 2.5select * from test; / / execution time is after update, before delete, select * from test; / / execution time is commit after delete

If you do not use the first select * from test of MVCC, you can read 1 record, while the second one will read 0 records. If the records read by multiple select range queries in the same transaction are inconsistent, it is a phantom read. After using MVVC, the two select statements read the same record.

At this point, the study of "what is the MVCC of InnoDB in mysql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Transaction learning two time more bank transaction help query utility same consistent next example pointer article method theory knowledge article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS Linux Apple vpn