Very slow delete on mysql base with subquery

前端 未结 4 548
星月不相逢
星月不相逢 2021-01-04 12:35

This mysql query is running for around 10 hours and has not finished. Something is horribly wrong.

Two tables (text and spam) are here. Spam stores the ids of spam e

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 13:07

    In my experience sub queries are often a cause of slow execution times in SQL statements, therefor I try to avoid them. Try this:

    DELETE tname FROM tname INNER JOIN spam ON (tname.old_id = spam.textid);
    

    Disclaimer: This query is not tested, make backups first! :-)

提交回复
热议问题