"I just discovered join_collapse_limit has been preventing the PostgreSQL planner from finding a much better join order. In my case, increasing the limit to 10 (from the default of 8) allowed the planner to improve search time from ~30 secs to ~1 ms, which is much more acceptable."
Docs "By default, this variable is set the same as from_collapse_limit, which is appropriate for most uses."
Could very well apply to Lemmy!!