logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma
commit: bd4926288e6b5d8d3e4439d83e30fa0211045d0b
parent: 1d1271ca1e8a8d1fe6322442d39a8b6fa57a0a7a
Author: lain <lain@soykaf.club>
Date:   Mon, 26 Mar 2018 10:31:22 +0200

Speed up follower query.

Diffstat:

Mlib/pleroma/user.ex2+-
Mpriv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs1+
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex @@ -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)} diff --git a/priv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs b/priv/repo/migrations/20180325172351_add_follower_address_index_to_users.exs @@ -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