Does php need to use mysql lock?

藏色散人
Release: 2023-02-25 16:44:02
Original
2857 people have browsed it

Does php need to use mysql lock?

Does php need to use mysql lock?

Under normal circumstances, MYSQL will automatically add tables during update operations Lock. No explicit locking is required. Unless the data requires strict logical writing order.

Before executing the query statement (SELECT), read locks will be automatically added to all tables involved. Before update operations (UPDATE, DELETE, INSERT, etc.) are performed, write locks will be automatically added to the tables involved. This The process does not require user intervention. Therefore, users generally do not need to directly use the LOCK TABLE command to explicitly lock the MyISAM table.

Related introduction:

Page level: Engine BDB.

Table level: engine MyISAM, understood as locking the entire table, which can be read at the same time, but cannot be written

Row level: engine INNODB, a single row of records is locked

1 ) Table-level lock: low overhead, fast locking; no deadlock; large locking granularity, the highest probability of lock conflict, and the lowest concurrency.

2) Row-level locks: high overhead, slow locking; deadlocks may occur; the locking granularity is the smallest, the probability of lock conflicts is the lowest, and the degree of concurrency is also the highest.

3) Page lock: The cost and locking time are between table locks and row locks; deadlocks will occur; the locking granularity is between table locks and row locks, and the concurrency is average.

Recommended tutorial:PHP tutorial

The above is the detailed content of Does php need to use mysql lock?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!