简体   繁体   English

MyISAM:如何选择而不在等待正在运行的DELETE的情况下进行选择?

[英]MyISAM: How to SELECT without lock-waiting with a running DELETE?

I have a table with 30 million records, using MyISAM engine. 我有一个表,使用MyISAM引擎记录了3000万条记录。 I have recurrent DELETE statements every 15 minutes to clean the table from old records. 我每隔15分钟执行一次DELETE语句来清除旧记录中的表。

Using: 使用:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM mytable WHERE id=123;

while a 'DELETE FROM mytable...' is running (which takes from 30 - 60 seconds). 正在运行“从mytable删除...”(耗时30-60秒)。

Will the SELECT statement return dirty records without locking? SELECT语句会返回脏记录而不锁定吗? Or will the table lock be respected and wait 30 seconds then return the results? 还是会尊重表锁并等待30秒然后返回结果? Is there a way to get a MyISAM table to return SELECT queries while DELETE has a table lock? 有没有一种方法可以使MyISAM表在DELETE具有表锁的情况下返回SELECT查询?

Thanks. 谢谢。

The DELETE statement supports the following modifiers: DELETE语句支持以下修饰符:

If you specify LOW_PRIORITY, the server delays execution of the DELETE until no other clients are reading from the table. 如果指定LOW_PRIORITY,则服务器将延迟执行DELETE,直到没有其他客户端从表中读取。 This affects only storage engines that use only table-level locking (such as MyISAM, MEMORY, and MERGE). 这仅影响仅使用表级锁定的存储引擎(例如MyISAM,MEMORY和MERGE)。

u can use 你可以用

DELETE LOW_PRIORITY FROM mytable ......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM