Fix timeouts in source:<url> searches and bookmarklet.
* Change the source index on posts from `(lower(source) gin_trgm_ops) WHERE source != ''` to just `(source gin_trgm_ops)`. The WHERE clause prevented the index from being used in source:<url> searches because we didn't specify the `source != ''` clause in the search itself. Excluding blank sources only saved a marginal amount of space anyway. This fixes timeouts in source:<url> searches and in the bookmarklet (since we do a source dupe check on the upload page too). * Also switch from indexing `lower(name)` to `name` on pools and users. We don't need to lowercase the column because GIN indexes can be used with both LIKE and ILIKE queries.
This commit is contained in:
@@ -197,7 +197,7 @@ class PostQueryBuilder
|
||||
|
||||
if q[:source]
|
||||
if q[:source] == "none"
|
||||
relation = relation.where("posts.source = ''")
|
||||
relation = relation.where_like(:source, '')
|
||||
else
|
||||
relation = relation.where_ilike(:source, q[:source].downcase + "*")
|
||||
end
|
||||
@@ -205,7 +205,7 @@ class PostQueryBuilder
|
||||
|
||||
if q[:source_neg]
|
||||
if q[:source_neg] == "none"
|
||||
relation = relation.where("posts.source != ''")
|
||||
relation = relation.where_not_like(:source, '')
|
||||
else
|
||||
relation = relation.where_not_ilike(:source, q[:source_neg].downcase + "*")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user