I'm testing the DB queries required for a Craft query and I realized that adding the title field to the eager loading doesn't change anything. So it seems like the title is retrieved by default.


{% set entries = craft.entries.section('whatever').relatedTo(tag).with([
]).all() %}

Has the same performance than:

{% set entries = craft.entries.section('whatever').relatedTo(tag).with([
]).all() %}

So, my assumption is that I need to provide only custom fields created by myself for the entry, when eager loading queries.

I didn't find this information in the docs.

1 Answer 1


The keyword when it comes to "eager-loading elements" is elements. In Craft parlance, an element type is one of Assets, Categories, Entries, etc. See the definition of elements.

As per the docs:

The purpose of the with param is to tell Craft which sub-elements you’re going to be needing in advance, so that it can fetch them all up front, in as few queries as possible.

So it only makes sense to use the with parameter with custom fields that are relational field types (Assets, Categories, Entries, etc.) that return sub-elements, in addition to matrix blocks and image transform indexes.

All other custom fields (with the possible exception of those added by third-party plugins) don't require eager-loading, as they are available directly on the populated element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.