Home Database Mysql Tutorial InnoDB的多版本并发控制(MMVC)

InnoDB的多版本并发控制(MMVC)

Jun 01, 2016 pm 01:13 PM
version number Record

InnoDB的MVCC之(乐观锁),是通过在每行记录保存两个隐藏列来实现的。这两个列,一个是存创建时间,一个是删除时间,这里的时间指的是,系统版本号,并不是真正的时间值。

每开始一个新的事务,系统版本号都会自动递增。事务开始时刻的系统版本号会作为事务的版本号,用来和查询到的每行记录版本号比较。

下面看一个在REPEATABLE READ(可重复读)隔离级别下,MVCC的具体操作:

SELECT

InnoDB会根据以下两个条件检查每行记录:

1、InnoDB只查找版本小于或等于当前事务版本的数据行,这样可以确保事务读取的行,是在事务开始前就已经存在的,或者是事务自身插入或者修改过的数据。

2、行的删除版本要么未定义,要么大于当前事务的版本。这可以确保事务赢取到的行,在事务开始前未被删除。

只有符合上述两个条件的记录,能能返回做为查询结果。

INSERT

InnoDB为新插入的每一行保存当前系统版本号作为行版本号。

DELETE

InnoDB为删除的每一行保存当前系统版本号作为行删除标识。

UPDATE

InnoDB为插入一行新记录,保存当前系统版本号作为行版本号,同时保存当前系统版本号到原来的行作为删除标识。

----------------------------------------------------------------------------------------------------------------------------------------------------------

保存这两个额外的系统版本号,使大多数读操作都可以不用加锁。这样设计使得读数据操作很简单,性能很好。并且也能保证只会读取到符合标准的行。不足之处是每行记录都需要额外的存储空间,需要做更多的检查工作,以及一些额外的维护工作。

MVCC只在REPEATABLE READ(可重复读)和READ COMMITTED(提交读)两个隔离级别下工作。其他两个隔离级别都和MVCC不兼容。READ UNCOMMITTED(未提交读)总是读取最新的数据行,而SERIALIZBLE(可串行化)则会对所有读取的行加锁。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Where can I view the records of things I have purchased on Pinduoduo? How to view the records of purchased products? Mar 12, 2024 pm 07:20 PM

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

How to view and manage Linux command history How to view and manage Linux command history Aug 01, 2023 pm 09:17 PM

How to View Command History in Linux In Linux, we use the history command to view the list of all previously executed commands. It has a very simple syntax: history Some options for pairing with the history command include: Option description -c clears the command history for the current session -w writes the command history to a file -r reloads the command history from the history file -n Limit the number of output of recent commands Simply run the history command to see a list of all previously executed commands in a Linux terminal: In addition to viewing command history, you can also manage command history and perform modifications to previously executed commands , reverse search command history or even delete history completely

How to check call history in iPhone and export it? How to check call history in iPhone and export it? Jul 05, 2023 pm 12:54 PM

Call recording in iPhone is often underestimated and is one of the most critical features of iPhone. With its simplicity, this feature is of vital importance and can provide important insights about the calls made or received on the device. Whether for work purposes or legal proceedings, the ability to access call records can prove invaluable. In simple terms, call history refers to the entries created on your iPhone whenever you make or receive a call. These logs contain key information, including the contact's name (or number if not saved as a contact), timestamp, duration, and call status (dialed, missed, or not answered). They are a concise record of your communication history. Call history includes call history strips stored on your iPhone

How to view your medication log history in the Health app on iPhone How to view your medication log history in the Health app on iPhone Nov 29, 2023 pm 08:46 PM

iPhone lets you add medications to the Health app to track and manage the medications, vitamins and supplements you take every day. You can then log medications you've taken or skipped when you receive a notification on your device. After you log your medications, you can see how often you took or skipped them to help you track your health. In this post, we will guide you to view the log history of selected medications in the Health app on iPhone. A short guide on how to view your medication log history in the Health App: Go to the Health App>Browse>Medications>Medications>Select a Medication>Options&a

Debian version numbers, codenames and software sources Debian version numbers, codenames and software sources Feb 20, 2024 am 09:01 AM

Debian is one of the largest distributions of Linux systems, but its version naming has always troubled me. Therefore, I sorted out the naming and relationships of various Debian versions. Version number (number) Debian version number is directly represented by numbers, such as Debian8, 9, 10, 11 and so on. Starting with Debian 6, every major distribution will add 1 to the original number. For example, Debian12 will be released in 2023. Based on the current version, small updates are represented by increasing decimals. For example, after Debian 12.0 is released, the subsequent updated versions are 12.1, 12.2, etc. The version number is relatively conventional and in line with general knowledge. Version code (nickname) In addition to the version number,

C# Development Advice: Logging and Monitoring Systems C# Development Advice: Logging and Monitoring Systems Nov 22, 2023 pm 08:30 PM

C# Development Suggestions: Logging and Monitoring System Summary: In the software development process, logging and monitoring systems are crucial tools. This article will introduce the role and implementation suggestions of logging and monitoring systems in C# development. Introduction: Logging and monitoring are essential tools in large-scale software development projects. They can help us understand the running status of the program in real time and quickly discover and solve problems. This article will discuss how to use logging and monitoring systems in C# development to improve software quality and development efficiency. The role of logging system

How to log and monitor Java development projects How to log and monitor Java development projects Nov 03, 2023 am 10:09 AM

How to log and monitor Java development projects 1. Background introduction With the rapid development of the Internet, more and more companies have begun to develop Java and build various types of applications. In the development process, logging and monitoring are an important link that cannot be ignored. Through logging and monitoring, developers can discover and solve problems in time to ensure the stability and security of applications. 2. The importance of logging 1. Problem tracking: When an application error occurs, logging can help us quickly locate the problem.

How to check the current version number in Python_How to check the current version number in Python How to check the current version number in Python_How to check the current version number in Python Apr 02, 2024 pm 06:50 PM

1. First enter the Ubuntu system, and then use ‘Ctrl+Alt+T’ to open the Ubuntu command line terminal. 2. Then Ubuntu systems generally include two versions of Python, python2 and python3. When we query the python version specified by the system by default, we use the command [python --version] to query. 3. Then the Ubuntu system generally contains two versions of Python, python2 and python3. When we query the corresponding python version, we use the command to query, the command [python2--version]/[python3--versi

See all articles