myisam即使在处理“选择"查询时也将表锁定在表上? [英] myisam place table-lock on table even when dealing with 'select' query?

查看:69
本文介绍了myisam即使在处理“选择"查询时也将表锁定在表上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读这本书High Performance MySQL,其中提到:

i am reading the book High Performance MySQL, it mentions:

performing one query per table uses table locks more efficiently: the queries 
will lock the tables invididually and relatively briefly, instead of locking 
them all for a longer time.

即使selecting发生什么,MyISAM也会放置表锁?有人可以解释一下吗?

MyISAM places table-lock even when selecting something? can someone explain a little bit?

推荐答案

MyISAM具有不同类型的锁. SELECT操作会在表上放置 READ LOCK .只要没有活动的写锁定,在任何给定时间都可以有多个活动的读锁定.修改表的操作,例如. INSERTUPDATEDELETEALTER TABLE在桌上放置写锁.只有在没有活动的读锁时,写锁才可以放在表上;如果存在活动的读锁,则所有活动的读锁都到期后,MyISAM会将要激活的写锁排入队列.

MyISAM has different kinds of locks. A SELECT operation places a READ LOCK on the table. There can be multiple active read locks at any given time, as long as there are no active WRITE LOCKS. Operations that modify the table, eg. INSERT, UPDATE, DELETE or ALTER TABLE place a WRITE LOCK on the table. Write lock can only be placed on a table when there are no active read locks; If there are active read locks, MyISAM queues the write lock to be activated as soon as all active read locks are expired.

同样,当存在活动的写锁时,尝试在表上放置读锁将使该锁(以及相关的查询)排队,直到表上的写锁到期为止.

Likewise when there's an active write lock, attempting to place a read lock on a table will queue the lock (and the associated query) until write locks have expired on the table.

最终,这一切都意味着:

Ultimately this all means that:

  • 您可以拥有任意数量的活动读锁(也称为共享锁)
  • 您只能拥有一个活动的写锁(也称为互斥锁)

有关更多信息,请参见: http://dev.mysql .com/doc/refman/5.5/en/internal-locking.html

For more information see: http://dev.mysql.com/doc/refman/5.5/en/internal-locking.html

这篇关于myisam即使在处理“选择"查询时也将表锁定在表上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆