akkoma/test/pleroma/web/mastodon_api
Oneric 138b1aea2f stats: use cheaper peers query
This query is one of the top cost offenders during an instances
lifetime. For small instances it was shown to take up 30-50% percent of
the total database query time, while for bigger isntaces it still held
a spot in the top 3 — alost as or even more expensive overall than
timeline queries!

The good news is, there’s a cheaper way using the instance table:
no need to process each entry, no need to filter NULLs
and no need to dedupe. EXPLAIN estimates the cost of the
old query as 13272.39 and the cost of the new query as 395.74
for me; i.e. a 33-fold reduction.

Results can slightly differ. E.g. we might have an old user
predating the instance tables existence and no interaction with since
or no instance table entry due to failure to query nodeinfo.
Conversely, we might have an instance entry but all known users got
deleted since.
However, this seems unproblematic in practice
and well worth the perf improvment.

Given the previous query didn’t exclude unreachable instances
neither does the new query.
2025-01-07 20:27:28 +01:00
..
controllers stats: use cheaper peers query 2025-01-07 20:27:28 +01:00
views fix test 2025-01-05 16:22:38 +00:00
masto_fe_controller_test.exs Support elixir1.15 2023-08-03 17:44:09 +01:00
mastodon_api_controller_test.exs Support elixir1.15 2023-08-03 17:44:09 +01:00
mastodon_api_test.exs Support elixir1.15 2023-08-03 17:44:09 +01:00
update_credentials_test.exs update captcha version 2023-10-20 13:30:29 +01:00