Add an abstraction for preventing the 1+N queries problem
Summary:
Our code is quite complex in areas where we prevents the 1+N queries problem explained in a performance chapter.
This diff adds an abstraction for preventing this code.
Test Plan:
Run all examples mentioned in the doc-comments with logging the queries.
Generate and read docs.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Koolvin
Differential Revision: https://secure.phabricator.com/D2557