delete from historical_alarm where exists (select * from (select id from historical_alarm limit 1,5000) as a where a.id=historical_alarm.id);