Optimistic concurrency control

Optimistic concurrency control is a technique used for concurrency.

  • It is used in databases and internally by concurrent data structure libraries
  • It assumes that actions will generally complete without contention, so proceeds to perform the update immediately, then checks afterwards if the action can be committed or must be rolled back
  • Avoiding the use of locks provides a performance boost, especially for .NET code where a lock could require an expensive entry into kernel mode
  • Care must be taken in use and implementation, as high load can lead to increased contention, which increases the load etc.




Enable MySQL server query logging

  1. View current state of variables:
    SHOW VARIABLES LIKE "general_log%";
  2. Set log location:
    SET GLOBAL general_log_file = 'C:/Temp/QueryLog.log';
  3. Enable logging:
    SET GLOBAL general_log = 'ON';
  4. Disable logging again (for improved database performance and disk usage):
    SET GLOBAL general_log = 'OFF';