Why is table-level locking better than row-level locking for large tables?

Jason Baker picture Jason Baker · Aug 11, 2010 · Viewed 29.4k times · Source

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.

Answer

µBio picture µBio · Aug 11, 2010

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.