DevPinoy.org
A Filipino Developers Community

>>> First two to make 3 wins! <<<

Threaded benchmark for LOCK TABLES vs SELECT FOR UPDATE


posted by cruizer
02-07-2007

Downloads: 269
File size: 6.8kB
Views: 605
Threaded benchmark for LOCK TABLES vs SELECT FOR UPDATE
Filed under: ,
A .NET console app that I made to evaluate how the performance of record locking via SELECT ... FOR UPDATE versus LOCK TABLES in MySQL.

I created two classes, MySqlWithTableLockConnection and MySqlTestConnection. The former uses LOCK TABLES while the latter uses transactions (InnoDB table type) and SELECT ... FOR UPDATE.

With one or two threads (representing simultaneous users), the performance of each were roughly the same. As the number of threads were increased, the SELECT FOR UPDATE approach had a performance advantage of three to four times over the LOCK TABLES approach. The disparity grew larger as the number of threads increased.

The benchmark computes the average time it takes for one thread (session) to perform its transaction, as well as the total time it took for all records (I used 1000 records in my tests) to be serviced.

Copyright DevPinoy 2005-2008