<p>Craft <a href="https://craftcms.com/changelog#build2789" rel="noreferrer">2.6.2789</a> added this feature, which is seems you've reverse engineered. :)</p>

<blockquote>
  <p>It is now possible to eager-load Structure entries' and categories' descendants using the <code>'descendants'</code> handle.</p>
</blockquote>

CC BY-SA 3.0
2016-06-29T00:51:29.413Z
Easy points! And I see I should have searched the changelog, not the docs ;-)
Ben Parizek
CC BY-SA 3.0
2016-06-28T23:19:19.203Z
2016-06-28T23:19:19.203Z
Brad Bell
<p>In looking at the the <code>BaseElementModel:getDescendants()</code> method and saw it checks for eager loading elements named 'descendants.'</p>

<pre><code>// Eager-loaded?
if ($this-&gt;hasEagerLoadedElements('descendants'))
{
    return $this-&gt;getEagerLoadedElements('descendants');
}
</code></pre>

<p>I added <code>with</code> and the <code>descendants</code> condition to a Structure and the page is now loading with a few less queries.</p>

<pre><code>{% set entries = craft.entries({
    section: 'sectionHandle',
    limit: null,
    with: [
        'descendants'
    ]
}) %}
</code></pre>

<p>Can anybody explain what is happening here?</p>

<structure><eager-loading>
Eager Loading a Structure and descendants
# Eager Loading a Structure and descendants

(Asked by: username_0 on 2016-06-28)

In looking at the the BaseElementModel:getDescendants() method and saw it checks for eager loading elements named 'descendants.'
// Eager-loaded?
if ($this->hasEagerLoadedElements('descendants'))
{
    return $this->getEagerLoadedElements('descendants');
}

I added with and the descendants condition to a Structure and the page is now loading with a few less queries.
{% set entries = craft.entries({
    section: 'sectionHandle',
    limit: null,
    with: [
        'descendants'
    ]
}) %}

Can anybody explain what is happening here?

**Tags:** structure, eager-loading

---

## 1 answers

### Answer by username_1 on 2016-06-28. Score: 7 | Accepted answer

Craft [2.6.2789](https://craftcms.com/changelog#build2789) added this feature, which is seems you've reverse engineered. :)

> It is now possible to eager-load Structure entries' and categories' descendants using the `'descendants'` handle.

> **Comments:**
> **username_0**: Easy points! And I see I should have searched the changelog, not the docs ;-)  

---

