Make use of the indices.
Indices in postgresql rely on operators, so they won't be used if you use only functions.
This commit is contained in:
parent
79e44042bc
commit
b108aeee08
2 changed files with 24 additions and 6 deletions
|
|
@ -734,7 +734,16 @@ defmodule Pleroma.User do
|
|||
^processed_query
|
||||
)
|
||||
},
|
||||
where: not is_nil(u.nickname)
|
||||
where:
|
||||
fragment(
|
||||
"""
|
||||
(setweight(to_tsvector('simple', regexp_replace(?, '\\W', ' ', 'g')), 'A') ||
|
||||
setweight(to_tsvector('simple', regexp_replace(coalesce(?, ''), '\\W', ' ', 'g')), 'B')) @@ to_tsquery('simple', ?)
|
||||
""",
|
||||
u.nickname,
|
||||
u.name,
|
||||
^processed_query
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
@ -750,7 +759,7 @@ defmodule Pleroma.User do
|
|||
u.name
|
||||
)
|
||||
},
|
||||
where: not is_nil(u.nickname)
|
||||
where: fragment("trim(? || ' ' || coalesce(?, '')) % ?", u.nickname, u.name, ^query)
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue