PERF: Remove extra subquery in search.

I also noticed that removing the subquery helps the planner to plan
better.
This commit is contained in:
Guo Xiang Tan 2020-08-17 13:50:27 +08:00
parent 630ec7b49c
commit 248bebb8cd
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 1 additions and 3 deletions

View File

@ -1024,9 +1024,7 @@ class Search
def categories_ignored(posts)
posts.where(<<~SQL, Searchable::PRIORITIES[:ignore])
categories.id NOT IN (
SELECT categories.id WHERE categories.search_priority = ?
)
(categories.search_priority IS NULL OR categories.search_priority IS NOT NULL AND categories.search_priority <> ?)
SQL
end