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

后端 未结 5 1037
温柔的废话
温柔的废话 2020-12-23 16:51

According to the MySQL manual:

For large tables, table locking is often better than row locking,

Why is this? I would presume

5条回答
  •  Happy的楠姐
    2020-12-23 17:45

    Table locking enables many sessions to read from a table at the same time

    To achieve a very high lock speed, MySQL uses table locking

    "I would presume that row-level locking is better because" [you lock less data].

    First "better" is poorly defined in this page. It appears that better means "faster".

    Row-level locking cannot (in general) be faster because of contention for locks. Locking each row of a large result set means the very real possibility of a conflict with another large result set query and a rollback.

提交回复
热议问题