我有一个名为raw_detection
的非常大的MyISAM表(> 1亿条记录)。数据不断插入其中。当我需要执行任何长时间运行的操作,如备份,复杂查询,索引创建等时,插入将被锁定,直到长时间运行操作结束。有什么方法可以避免这种情况吗?
以下是挂起插入内容的查询示例:
insert into `agreagate_months`
select year(r.created_at), month(r.created_at), right_holder_id, city_id, count(distinct r.id) from
raw_detection r
join audio_sources aso on aso.id = r.`audio_source_id`
join cities c on c.id = aso.`city_id`
join track_right_holders tr on tr.`track_id` = r.`track_id`
where
r.duplicated = 0 and
r.score > 40 and
r.created_at >= '2014-11-1' and
r.created_at < '2014-12-1' and
tr.role = 'Interpreter'
group by 1,2,3,4;
MySQL版本是在具有4GB RAM和4个CPU的服务器上运行的MariDB 10.0.16