I am trying to delete child records in my database and I created this query:
DELETE post.*
FROM foro_post AS post
LEFT JOIN foro_thread AS thread USING(threadid)
WHERE thread.threadid IS NULL
The problem is that I want to limit because my table has more than 7,000,000 records.
Since I cannot use LIMIT with the query, I tried this and actually worked, but I'm not sure if this is an effective solution, or if it can be done better.
DELETE post.*
FROM foro_post AS post
LEFT JOIN foro_thread AS thread USING(threadid)
WHERE thread.threadid IS NULL
AND post.postid < 500
// Where < 500 should be increasing as I delete records
How can I do this more efficiently?
Thank!
source
share