Commit 40a61532 authored by Ariadne Conill's avatar Ariadne Conill

activity: when restricting deactivated users, precalculate the user list

the PostgreSQL query planner is easily confused due to the complexity of
certain queries we make.  while we plan to simplify these queries through
unification of activities and objects, we are not yet there.  it has been
discovered that using a precalculated list of deactivated users encourages
the query planner to prefer simpler indices instead of the
activity_visibility index.

accordingly, drop the subquery and precalc the user list instead.
parent 5effb2cb
Pipeline #16833 passed with stages
in 8 minutes and 23 seconds
......@@ -362,12 +362,12 @@ def query_by_actor(actor) do
def restrict_deactivated_users(query) do
deactivated_users =
from(u in true), select: u.ap_id)
|> Repo.all()
from(activity in query,
"? not in (SELECT ap_id FROM users WHERE info->'deactivated' @> 'true')",
where: not in ^deactivated_users
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment