Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats the use of SELECT .. FOR UPDATE when using Repeatable Read isolation?

When using Repeatable Read isolation, you are guaranteed that the rows you read using SELECT wont be modified until your transaction completes.

This seems to be similar to what SELECT .. FOR UPDATE offers.

So what is the point of using SELECT FOR UPDATE when using Repeatable Read isolation?

like image 757
pdeva Avatar asked Nov 18 '15 16:11

pdeva


1 Answers

When you read a record under Repeatable Read, you get a read-lock, but other transactions can also get a read lock, which might prevent you from making an update later. Using FOR UPDATE informs any other transactions which request a read lock that they should wait until you're finished updating the record.

like image 184
cliffordheath Avatar answered Nov 01 '22 17:11

cliffordheath