I am trying to delete about 2.2 million rows by a column called entity_id
from a table called url_rewrites
. There could be multiple rows with the same entity_id
. I got a file that I run which contains a row for each entity_id
, like this:
delete from url_rewrite where entity_id = 2128693;
...
...
Now, running this script takes a long time and the website that belongs to the DB is used of course. So every 5 or 10 minutes and sometimes faster I get a deadlock and the scripts stops so I have to restart it manually.
I tried adding locking the table for WRITE access with LOCK TABLES url_rewrite WRITE;
in the beginning of the script, but this stops the website from working correctly (it wont respond).
Is there any other way to run the script or delete those rows blocking the website?
Thanks!