Add database indexes

The new get(*)Memberships query was running quite slowly, I've added a couple of basic indexes which make the query 10x faster.

@imaginator Maybe it would be worth trying to find a postgres expert to help optimize our queries now we aren't doing just simple selects?