Jump to content

Lock single record...


ToonMariner

Recommended Posts

I have a process where I need to lock just one record of a table.  Locking the entire table would cripple the rest of the site simply due to the volume of request that use this table.

I have read that the InnoDB type supports this but I am not sure how to execute the lock on a single record - do the updates and then release the lock.

ANy help would be very much appreciated.
Link to comment
https://forums.phpfreaks.com/topic/30699-lock-single-record/
Share on other sites

From http://dev.mysql.com/doc/refman/5.0/en/internal-locking.html

[quote]InnoDB uses row locks and BDB uses page locks. For these two storage engines, deadlocks are possible because they automatically acquire locks during the processing of SQL statements, not at the start of the transaction.[/quote]

Yep, myisam doesn't have row-level locking.  You'll need to use innoDB (or switch to postgresql :P )
Link to comment
https://forums.phpfreaks.com/topic/30699-lock-single-record/#findComment-141532
Share on other sites

so I have an innodb type table and I need to perform 3 separate queries - an update, a query and another update depending on the last query.

How do I wrap these queries up so that a lock is gained on a row and only released when the last query is complete?
Link to comment
https://forums.phpfreaks.com/topic/30699-lock-single-record/#findComment-141832
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.