diff options
| author | lain <lain@soykaf.club> | 2019-01-20 00:31:17 +0100 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2019-01-20 00:31:17 +0100 | 
| commit | b108aeee082949e2e534f8bc406fdacb8924803d (patch) | |
| tree | 3e389825a1b4d941cda0c2f7dda538f11f865729 /lib | |
| parent | 79e44042bc08cf69274008e408cac912ae693afe (diff) | |
| download | pleroma-b108aeee082949e2e534f8bc406fdacb8924803d.tar.gz pleroma-b108aeee082949e2e534f8bc406fdacb8924803d.zip | |
Make use of the indices.
Indices in postgresql rely on operators, so they won't be used if you use only functions.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pleroma/user.ex | 13 | 
1 files changed, 11 insertions, 2 deletions
| diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index eb4218ebe..87815e11c 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -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 | 
