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 [[ http://www.phabricator.com/docs/phabricator/article/Performance_N+1_Query_Problem.html | 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
This commit is contained in:
vrana
2012-05-23 14:05:33 -07:00
parent 1377d349e1
commit 0446e636ea
4 changed files with 219 additions and 0 deletions

View File

@@ -63,6 +63,9 @@ are no longer paying the overhead of issuing hundreds of extra queries. This
will perform much better (although, as with all performance changes, you should
verify this claim by measuring it).
See also @{method:LiskDAO::loadRelatives} method which provides an abstraction
to prevent this problem.
= Detecting the Problem =
Beyond reasoning about it while figuring out how to load the data you need, the