The intent is sound: get the children and all of their children in a single query. The only time you're interested in the homepage's children, is when you are rendering the page tree, and you would (should) always do that by accessing the .children cached property. But .children does this:
for child in self.child_set.all().filter(is_content_object=False):
child.parent = self
children.append(child)
...which causes the prefetch to be invalidated by the is_content_object=False filter. Thus, this is actually the opposite of an optimisation; it actually adds three queries (and about 20ms cold-cache load).
Previously, getting the homepage from
PageManager
did this:The intent is sound: get the children and all of their children in a single query. The only time you're interested in the homepage's children, is when you are rendering the page tree, and you would (should) always do that by accessing the
.children
cached property. But.children
does this:...which causes the prefetch to be invalidated by the
is_content_object=False
filter. Thus, this is actually the opposite of an optimisation; it actually adds three queries (and about 20ms cold-cache load).