PERF: Use a subquery when excluding a tag from topic query. (PR #14577)

When a tag with alot of topics is used, we end up allocating a Ruby array of all the topic ids. Instead, we can just use a subquery here and handle all of the exclusion logic in PG.

Follow-up to ae13839f98b1b2530a4727a09feee89d7a6ebd88


distinct seems unneeded, the planner should drop it anyway

Good point and I realized there is a unique index on topic_id and tag_id