mysql MVCC understanding of the principles

      MVCC Multi Version Control: refers to a concurrent technology to improve. The first database system between concurrency can only read, write, write, read, write should be blocked. After the introduction of multi-version, only with mutual blocking between writing, the other three operations in parallel, which greatly improves the concurrency of InnoDB. Internally, the Postgres with multi-version on different rows, InnoDB is implemented in undolog, you can retrieve historical versions of data through undolog. Retrieve historical versions of data can be provided to the user to read (as defined by the isolation level, some of the read request can only see the older version of the data), you can also overwrite the data on the data page at the time of the rollback. In the internal InnoDB, a record will be read and write transactions globally active array, which is mainly used visibility judgment transaction.
      Most MySQL transactional storage engine to achieve not simple row-level locking. Based on lifting consider concurrent performance, they are generally at the same time to achieve a multi-version concurrency control (MVCC). Not just MySQL, including Oracle, PostgreSQL and other database systems have achieved MVCC, but their implementation mechanism is not the same, because MVCC does not have a uniform standard. In many cases MVCC locking operation is avoided, and therefore lower cost. Most of the MVCC have achieved non-blocking read and write operations only lock the necessary rows.
     Realization of MVCC, by saving a snapshot of the data at a point in time to achieve. In other words, no matter how long you need to perform each transaction sees the data is consistent. Depending on the time of the transaction began, each thing on the same table, the same time see the data may not be the same. Different storage engines MVCC implementation is different, typically optimistic (optimistic) and pessimistic concurrency control (pessimistic) concurrency control.

     MVCC only work in two REPEATABLE READ and READ COMMITTED isolation level. The other two are not compatible with the isolation level and MVCC, because READ UNCOMMITTED always read the latest data line, rather than in line with the current transaction version of the row, but SERIALIZABLE will read all rows locked.

    MVCC advantages and disadvantages:

    MVCC's goal is to pursue high concurrent database processing capabilities to achieve non-blocking reads.

    But save these two additional system version number, the most read operations can never be locked, so that design makes a data read operation is very simple, very good performance, and can only be read to ensure compliance with the standard line, insufficient place every rows require additional storage space, need to do more checking line of work, as well as some additional maintenance work.

 

Guess you like

Origin www.cnblogs.com/xuzhujack/p/11009033.html