Locking
There are two types of locking:
- Internal locking: MySQL performs internal locking within the server itself to manage contention for table contents by multiple sessions
- External locking: MySQL gives the option to client sessions to acquire a table lock explicitly for preventing other sessions from accessing the table
Internal locking: There are mainly two types of locks:
- Row-level locks: The locking is granular to the level of rows. Only the rows that are accessed are locked. This allows simultaneous write access by multiple sessions, making them suitable for multi-user, highly concurrent, and OLTP applications. Only
InnoDB
supports row-level locks. - Table-level locks: MySQL uses table-level locking for
MyISAM
,MEMORY
, andMERGE
tables, permitting only one session to update those tables at a time. This locking level makes these storage engines more suitable for read-only, read-mostly, or single-user applications.
Refer to https://dev.mysql.com/doc/refman/8.0/en/internal-locking.html and...