31st Day MySQL concurrency control, storage engine Introduction, user Rights Management, cache management, and data type selection

Source: Internet
Author: User

I. Concurrency control for MySQL

1, MySQL concurrency control at the server layer and the storage engine layer completed

Locks: Lock

Read lock: Shared lock, can be read by several user colleagues, but cannot write

Write Lock: Exclusive lock,

Lock granularity: Lock table when lock table range (such as a user read the first three rows, one user writes the last line)

Table-level Lock: InnoDB table-level lock

Row-level Lock: Myisa row-level lock (lock control Complex)

Deadlock: A request B,b request a (oneself can negotiate unlock)

Lock classification:

Implicit lock: Auto-complete by the storage engine

Explicit Lock: User can manually apply a lock, table-level lock

Manual locking: Server-level implementation

LOCK TABLES tb1 {read| WRITE},......

UNLOCK TABLES; release lock

Example: >use hellodb;

>lock TABLES students READ;

FLUSH TABLES with READ LOCK; Close the table and perform a read lock globally

UNLOCK TABLES;

The InnoDB storage engine also supports another explicit lock (only selected rows are locked)

SELECT ... LOCK in SHARE MODE;

SELECT ... For UPDATE;


2. Business: ACID

A transaction is an execution unit: Multiple SQL statements are either executed or not executed.

31st Day MySQL concurrency control, storage engine Introduction, user Rights Management, cache management, and data type selection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.