According to the MySQL manual:
For large tables, table locking is often better than row locking,
Why is this? I would presume that row-level locking is better because when you lock on a larger table, you're locking more data.
Row locking needs more memory than table or page level locking.
Have to acquire many more locks with row locking, which expends more resources
From http://www.devshed.com/c/a/MySQL/MySQL-Optimization-part-2/
Advantages of row-level locking:
Disadvantages of row-level locking:
Table locks are superior to page-level or row-level locks in the following cases:
UPDATE tbl_name SET column=value WHERE unique_key_col=key_value;
DELETE FROM tbl_name WHERE unique_key_col=key_value;
from the (pre-edit) link
Slower than page-level or table-level locks when used on a large part of the table because you must acquire many more locks
use a row level lock if you are only hitting a row or two. If your code hits many or unknown rows, stick with table lock.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With