简体   繁体   中英

Delete bulk data from MySQL table

I have a MySQL database table which has more than 250000 of records. Now I like to delete around 230000 records under specific condition. When I am trying to do this, I am not able to achieve it by anyway since it is completely loading for all the time.

I have tried by writing PHP script to read the data one by one and delete it. Also I tried to take the back up of the data to try by dropping the table. But I am not able to take the backup. Also I tried to re-index, that also didn't work.

I got totally stuck up with this issue and couldn't find any way to fix.

Please anyone help me if you know any way to sort this out.

Thanks a lot, Ram

You need to index the table on the fields that you have in your WHERE conditions. In your example:

DELETE FROM Participator WHERE EventID = 180; 

The index should be on EventID. Add the index with the following statement:

ALTER TABLE Participator add index(EventID);

You can find more info about mysql indexes and how to use them here: https://dev.mysql.com/doc/refman/5.7/en/mysql-indexes.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM