开发者

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

I have a table with 30 million records, using MyISAM engine. I have recurrent DELETE statements every 15 minutes to clean the table from old records.

Using:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT * FROM mytable WHERE id开发者_如何学Python=123;

while a 'DELETE FROM mytable...' is running (which takes from 30 - 60 seconds).

Will the SELECT statement return dirty records without locking? Or will the table lock be respected and wait 30 seconds then return the results? Is there a way to get a MyISAM table to return SELECT queries while DELETE has a table lock?

Thanks.


The DELETE statement supports the following modifiers:

If you specify LOW_PRIORITY, the server delays execution of the DELETE until no other clients are reading from the table. This affects only storage engines that use only table-level locking (such as MyISAM, MEMORY, and MERGE).

u can use

DELETE LOW_PRIORITY FROM mytable ......
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜