Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use Shared Locking (Read Locking)

Can someone explain when shared locks should be used. If I understand correctly, shared locks are used when reading and exclusive locks are used while writing.

But why can't I just wait while a mutex is locked when doing a read.

like image 940
Baz Avatar asked May 03 '26 00:05

Baz


1 Answers

It is for improving performance. Multiple concurrent reads then won't have to happen sequentially, which may be a great bonus if the structure is read frequently. (But still the data read will be consistent and up to date.)

like image 168
zeller Avatar answered May 04 '26 22:05

zeller



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!