Skip to content
Snippets Groups Projects
Commit bd492628 authored by lain's avatar lain
Browse files

Speed up follower query.

parent 1d1271ca
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -265,7 +265,7 @@ defmodule Pleroma.User do
def get_followers(%User{id: id, follower_address: follower_address}) do
q = from u in User,
where: ^follower_address in u.following,
where: fragment("? <@ ?", ^[follower_address], u.following),
where: u.id != ^id
{:ok, Repo.all(q)}
......
......@@ -4,5 +4,6 @@ defmodule Pleroma.Repo.Migrations.AddFollowerAddressIndexToUsers do
@disable_ddl_transaction true
def change do
create index(:users, [:follower_address], concurrently: true)
create index(:users, [:following], concurrently: true, using: :gin)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment