A platform for community discussion. Free, open, simple.
PERF: Speed up moving posts on large databases
Gerhard Schlager71849242faf8
diff --git a/app/models/post_mover.rb b/app/models/post_mover.rbindex ca2228653a7..1037c3ff00e 100644--- a/app/models/post_mover.rb+++ b/app/models/post_mover.rb@@ -282,10 +282,10 @@ class PostMoverdef delete_post_repliesDB.exec <<~SQL- DELETE- FROM post_replies pr USING moved_posts mp, posts p, posts r- WHERE (pr.reply_post_id = mp.old_post_id OR pr.post_id = mp.old_post_id) AND- p.id = pr.post_id AND r.id = pr.reply_post_id AND p.topic_id <> r.topic_id+ DELETE FROM post_replies pr USING moved_posts mp+ WHERE (SELECT topic_id FROM posts WHERE id = pr.post_id) <>+ (SELECT topic_id FROM posts WHERE id = pr.reply_post_id)+ AND (pr.reply_post_id = mp.old_post_id OR pr.post_id = mp.old_post_id)SQLend