akkoma/lib/pleroma
Tusooa Zhu a9984c6da7
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

BUG: https://git.pleroma.social/pleroma/pleroma/-/issues/2758
2021-08-27 22:27:17 -04:00
..
activity Make activity search properly use GIN indexes 2021-08-27 22:27:17 -04:00
bbs
captcha
chat
config
conversation
docs
ecto_type
emails
emoji
gopher
gun
helpers
http
instances
mfa
migration_helper
migrators
object
password
reverse_proxy
telemetry
tesla/middleware
tests
upload
uploaders
user
web
workers
activity.ex
application.ex
application_requirements.ex
bookmark.ex
caching.ex
captcha.ex
chat.ex
clippy.ex
config.ex
config_db.ex
constants.ex
conversation.ex
counter_cache.ex
data_migration.ex
delivery.ex
ecto_enums.ex
emoji-test.txt
emoji.ex
filter.ex
following_relationship.ex
formatter.ex
frontend.ex
gun.ex
hashtag.ex
healthcheck.ex
html.ex
http.ex
instances.ex
job_queue_monitor.ex
jwt.ex
keys.ex
list.ex
logging.ex
maintenance.ex
maps.ex
marker.ex
mfa.ex
moderation_log.ex
notification.ex
object.ex
object_tombstone.ex
otp_version.ex
pagination.ex
password_reset_token.ex
registration.ex
release_tasks.ex
repo.ex
report_note.ex
reverse_proxy.ex
scheduled_activity.ex
signature.ex
stats.ex
thread_mute.ex
upload.ex
user.ex
user_invite_token.ex
user_relationship.ex
utils.ex
web.ex
xml_builder.ex