I have a table with about 1,000,000 rows, and I need to delete the same datas, so I use following SQL
delete
from history
where hid not in
(
select hid from
(
select min(hid) as hid
from history
group by `invitedkey`, `userkey`, `charge`
) as b
);
Here hid
is Primary, AUTO_INCREMENT, if the invitedkey, userkey, charge are the same, keep one data with minimum hid. but I run above SQL, I always get error
Lock wait timeout exceeded; try restarting transaction
And I googled, but there's no good answer, is there any ideas except increasing hardware configuration.