Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transactions in MySQL

What Will MySQL uses for the transactions?MVCC(Multi Version Concurrency Control) or Row Level Locking.?
If both how can we shift from one to another.

like image 563
Rohit Avatar asked Dec 30 '25 18:12

Rohit


1 Answers

This doesn't depend on MySQL itself, but on the used engine, e.g. InnoDB or MyIsam.


In the InnoDB transaction model, the goal is to combine the best properties of a multi-versioning database with traditional two-phase locking. InnoDB does locking on the row level and runs queries as nonlocking consistent reads by default, in the style of Oracle. The lock table in InnoDB is stored so space-efficiently that lock escalation is not needed: Typically, several users are permitted to lock every row in InnoDB tables, or any random subset of the rows, without causing InnoDB memory exhaustion.

(Source: http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-model.html)


MySQL uses table-level locking for MyISAM, MEMORY, and MERGE tables, allowing only one session to update those tables at a time, making them more suitable for read-only, read-mostly, or single-user applications.

(Source: http://dev.mysql.com/doc/refman/5.1/en/internal-locking.html)

like image 115
Benjamin M Avatar answered Jan 01 '26 11:01

Benjamin M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!