distraction.party/lib/pleroma/activity
Tusooa Zhu bd0eb1c675
Make activity search properly use GIN indexes
The original approach to search in GIN indexes is to use
`to_tsvector(text)` in the WHERE clause of the query. According to
postgres docs [pdoc], this method does not make use of the index,
while `to_tsvector(config, text)` does. This commit changed the
query to use the two-argument `to_tsvector()`.

[pdoc]: https://www.postgresql.org/docs/12/textsearch-tables.html

To obtain the search config in use, we make a query to the db first.
The `::regconfig::oid` hack is needed because Postgrex does not support
regconfig type directly [postgrexbug]. I use the conversion from and to
`oid` instead of `text` because I tested in the actual DB and querying
using the conversion via `text` is slow just as the one-argument
`to_tsvector()` variant.

[postgrexbug]: https://github.com/elixir-ecto/postgrex/issues/502

Backport of: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3519

Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/2758
2021-08-28 18:26:04 +02:00
..
ir Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework 2021-01-13 22:11:16 +03:00
html.ex Break out activity-specific HTML functions into Pleroma.Activity.HTML 2021-05-29 12:29:11 -05:00
queries.ex Let pins federate 2021-03-25 13:03:40 +03:00
search.ex Make activity search properly use GIN indexes 2021-08-28 18:26:04 +02:00