the PersonView::admins query currently does a seq scan on all persons because admin is not indexed.
Also, the CommunityView::is_mod_or_admin function does a seq scan on all persons because it uses PersonView::admins.
is_mod_or_admin is used in tons of places, e.g. createpost.
This PR adds an index on the admin field to improve the api/v3/site and community fetches.
It also replaces the is_mod_or_admin function to just return a boolean and also not do any seq scans.
This should improve page load times that fetch admins (e.g. / ) and also everything.
The PersonView::admins is the second-most expensive query after #3482 on lemmy.world with 1.5 million calls returning 10 million rows and 27 hours of execution time in one day. This should reduce that to almost zero.
I did not test this.