doesn’t this need deleting?
LEFT OUTER JOIN ( SELECT DISTINCT user_id FROM posts WHERE topic_id = :new_topic_id ) p ON (p.user_id = tu.user_id)
I don’t think so, it is still used here https://github.com/discourse/discourse/blob/444744dc665d5ada5e58040342eb72ac3221e6fd/app/models/post_mover.rb#L345
we can move it back as select instead of join FIX: Move notification level only when user posted · discourse/discourse@2c01125 · GitHub
I think having it in the
SELECT was a little bit faster than doing the
JOIN. It might be worth looking at the explain plan of both queries and use the faster one.
I think it auto optimises, but you might as well do a
once done feel free to merge
EXISTS aborts the subquery as soon as one row is found
The subquery will generally only be executed long enough to determine whether at least one row is returned