MYSIAM表 并发插入

上篇文章提到MyISAM表的读和写操作是串行的,但这只是总体而言的。在一定条件下,MyISAM表也支持查询和插入操作的并发进行。

MyISAM存储引擎的系统变量concurrent_insert,专门用以控制其并发插入的行为。

concurrent_insert(官方文档对这个参数的说明)

If AUTO (the default), MySQL permits INSERT and SELECT statements to run concurrently for MyISAM tables that have no free blocks in the middle of the data file. If you startmysqld with--skip-new, this variable is set toNEVER.

This variable can take the values shown in the following table. The variable can be assigned using either the name values or corresponding integer values.

ValueDescription
NEVER (or 0)Disables concurrent inserts
AUTO (or 1)(Default) Enables concurrent insert for MyISAM tables that do not have holes
ALWAYS (or 2)Enables concurrent inserts for all MyISAM tables, even those that have holes. For a table with a hole, new rows are inserted at the end of the table if it is in use by another thread. Otherwise, MySQL acquires anormal write lock and inserts the row into the hole.

0:不允许并发插入

1:(默认值)如果MYISAM表中没有空洞(即表中间没有被删除的行),MYSIAM允许在一个进程读表的同时,另一个进程从表尾插入记录。

2:无论MYSIAM表有没有空洞,都允许在表尾并发的插入记录。如果是得到了普通的写锁(即只有自己一个会话在使用表),那就可以将数据插入到空洞中。


当会话session1获得表的READ LOCAL锁,该线程可以对表进行查询操作,但不能对表进行操作;其他的会话(session2)虽然不能对表进行删除和

更新操作,但却可以对表进行并发插入操作,这里假设该表中间不存在空洞。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值