8.11.3 Concurrent Inserts(并发插入)

MySQL的MyISAM存储引擎支持并发插入以减少读写竞争。当表没有中间的删除行时,INSERT语句可以同时添加行到表尾部,而SELECT语句能并发读取数据。多条INSERT语句会被顺序执行,结果可能不会立即显示。.concurrent_insert系统变量可调整并发插入行为,默认允许并发插入。使用二进制日志时,并发插入会转换为普通插入以确保备份的准确性。
摘要由CSDN通过智能技术生成

The MyISAM storage engine supports concurrent inserts to reduce contention between readers and writers for a given table: If a MyISAM table has no holes in the data file (deleted rows in the middle), an INSERT statement can be executed to add rows to the end of the table at the same time that SELECT statements are reading rows from the table.

MyISAM存储引擎支持并发插入减少读者与写入者之间的竞争对于一个给定的表:如果一个MyISAM表没有漏洞数据文件(删除行中间),可以将行添加到执行INSERT语句表在同一时间结束,SELECT语句从表中读取行。

If there are multiple INSERT statements, they are queued and performed in sequence, concurrently with the SELECT statements. The results of a concurrent INSERT may not be visible immediately.

如果有多条INSERT语句,则将它们排队并按顺序执行,与SELECT语句并发执行。并发INSERT的结果可能不会立即可见。

The concurrent_insert system variable can be set to modify the concurrent-insert processing. By default, the variable is set to AUTO (or 1) and concurrent inserts are handled as just described. If concurrent_insert is set to NEVER (or 0), concurrent inserts are disabled. If the variable is set to ALWAYS (or 2), concurrent inserts at the end of the table are permitted even for tables that have deleted rows. See also the description of the concurrent_insert system variable.

可以设置系统变量concurrent_insert来修改并发插入处理。默认情况下,该变量被设置为AUTO(或1),并发插入的处理方法如前所述。如果concurrent_insert设置为NEVER(或0),则禁用并发插入。如果变量被设置为ALWAYS(或2),即使对于已删除行的表,也允许在表的末尾进行并发插入。请参见concurrent_insert系统变量的描述。

If you are using the binary log, concurrent inserts are converted to normal inserts for CREATE ... SELECT or INSERT ... SELECT statements. This is done to ensure that you can re-create an exact copy of your tables by applying the log during a backup operation.

如果您正在使用二进制日志,则并发插入将被转换为CREATE…选择或插入…SELECT语句。这样做是为了确保您可以通过在备份操作期间应用日志来重新创建表的精确副本。

See Section 5.4.4, “The Binary Log”. In addition, for those statements a read lock is placed on the selected-from table such that inserts into that table are blocked. The effect is that concurrent inserts for that table must wait as well.

此外,对于这些语句,将在select -from表上放置读锁,这样插入到该表的操作就会被阻塞。其结果是,该表的并发插入也必须等待

With LOAD DATA, if you specify CONCURRENT with a MyISAM table that satisfies the condition for concurrent inserts (that is, it contains no free blocks in the middle), other sessions can retrieve data from the table while LOAD DATA is executing. Use of the CONCURRENT option affects the performance of LOAD DATA a bit, even if no other session is using the table at the same time.

使用LOAD DATA,如果为满足并发插入条件的MyISAM表指定CONCURRENT(即,它中间不包含空闲块),则其他会话可以在LOAD DATA执行时从表中检索数据。使用CONCURRENT选项会稍微影响LOAD DATA的性能,即使没有其他会话同时使用该表。

If you specify HIGH_PRIORITY, it overrides the effect of the --low-priority-updates option if the server was started with that option. It also causes concurrent inserts not to be used.

如果指定HIGH_PRIORITY,它将覆盖——low-priority-updates选项(如果服务器是用该选项启动的)的效果。它还会导致不使用并发插入。

For LOCK TABLE, the difference between READ LOCAL and READ is that READ LOCAL permits nonconflicting INSERT statements (concurrent inserts) to execute while the lock is held. However, this cannot be used if you are going to manipulate the database using processes external to the server while you hold the lock.

对于LOCK TABLE, READ LOCAL和READ之间的区别是,READ LOCAL允许在锁被持有时执行不冲突的INSERT语句(并发插入)。但是,如果您打算在持有锁的同时使用服务器外部的进程来操作数据库,则不能使用此方法。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值