I have a very large MyISAM table named raw_detection
(>100 million records). Data is continuously being inserted on it. When I need to do any long running operation like backups, complex queries, index creation, etc. the inserts get locked until the long running operation ends. Is there any way to avoid this?
Here is an example of query that hangs the inserts:
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 version is MariDB 10.0.16 running on a server with 4GB RAM and 4 CPUs