[WIP] Improve apps and collection api performance

https://bugzilla.mozilla.org/show_bug.cgi?id=956987

WIP because I haven't run all the tests yet and there are a couple more areas where we can improve stuff, but this cuts by *half* the number of queries made in certain cases.