Home  >  Article  >  Backend Development  >  Does php need to use mysql lock?

Does php need to use mysql lock?

藏色散人
藏色散人Original
2019-09-30 09:07:042892browse

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!

Statement:
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