我正在尝试删除数据库中的孤立帖子,并且创建了以下查询:
DELETE post.*
FROM foro_post AS post
LEFT JOIN foro_thread AS thread USING(threadid)
WHERE thread.threadid IS NULL
问题是我想限制因为我的表有超过 7,000,000 条记录。
因为我不能在查询中使用 LIMIT,所以我尝试了这个并且确实有效,但我不确定它是否是一个有效的解决方案,或者它是否可以做得更好。
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
我怎样才能更有效地做到这一点?