To some extent, yes.
When it comes to InnoDB, you can choose what rows can get locked. It is not so much a particular setting for the DB Connection. It is a specific query you have to call before doing UPDATEs.
SELECT ... FOR UPDATE
SELECT ... LOCK IN SHARE MODE
This can initiate exclusive or shared row locks based on the result set of those SELECTs.
You can find more information on this in the MySQL Documentation.
I wrote earlier posts on using these:
Aug 08, 2011
: Are InnoDB Deadlocks exclusive to INSERT/UPDATE/DELETE?Are InnoDB Deadlocks exclusive to INSERT/UPDATE/DELETE?Jan 02, 2012
: LOCK IN SHARE MODELOCK IN SHARE MODEMar 18, 2012
: select for update gives error on indexed columnselect for update gives error on indexed columnMay 09, 2012
: Transaction Lock Timeouts When Updating a RowTransaction Lock Timeouts When Updating a RowMay 13, 2012
: Cannot update certain rows in innodb tablesCannot update certain rows in innodb tablesAug 10, 2012
; Similar function NOWAIT in MySQLSimilar function NOWAIT in MySQL
With regard to sessions and connections
- Performing
SELECT ... FOR UPDATE
will initiate locks on rows you intend to update and still permit other DB Connections to read. - Performing
SELECT ... LOCK IN SHARE MODE
essentially does the reverse - lock rows for you to read
- allow SELECTs of the same locked rows
- prevent connections from doing
SELECT ... FOR UPDATE
or direct DML
The only advantage I see in using these SELECT
queries is preventing needless deadlocks on pages.
I hope this helps !!!