<p><strong>You're exactly right: The advantage of using the variable is that you can re-use it throughout your template, which helps keep things DRY.</strong></p>

<p>When you use <code>craft.entries</code> in your template, Craft serves up an <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel">ElementCriteriaModel</a> — This is an object that <em>knows how</em> to query the system for a set of entries... but it doesn't actually perform that query until you either <em>(a)</em> call the <code>.find()</code> method, or <em>(b)</em> use the object as an interable in a loop.</p>

<p>In other words, the first time you try to get an Array from the ElementCriteriaModel (either by creating the array explicitly with <code>find()</code> or by creating it implicitly by treating it as an Array — THAT'S when Craft does the work of perofmring the query.</p>

<p>Unless you need to do an operation directly on the array, you don't actually need to call the <code>.find()</code> method. It's perfectly acceptable to let Craft do the smart thing automatically:</p>

<pre><code>{% set entries = craft.entries.section(...) %}
{% for entry in entries %}
   ...
{% endfor %}
</code></pre>

<p>There's often a slight advantage to doing it this way, because it means if that variable never gets used (perhaps it's hidden away in an unsatisfied conditional or something), Craft never does the work of performing the query.</p>

CC BY-SA 3.0
2015-07-13T15:22:22.407Z
2015-07-13T15:22:22.407Z
Michael Rog
<p>As I understand, I have (at least) the following two possibilities to list entries of a channel:</p>

<p>Possibility 1:</p>

<pre><code>{% for entry in craft.entries.section('example').find() %}
</code></pre>

<p>Possibility 2:</p>

<pre><code>{% set entries = craft.entries.section('example') %}
{% for entry in entries %}
</code></pre>

<p>Unfortunately, I am not experienced enough to understand the advantages and the disadvantates of these both possibilities (e.g. performance related etc.)</p>

<p>The only thing I see: in possibility 2 I can reuse "entries" within the same template.</p>

<p>I would be grateful for some further information on the differences.</p>

<p>Thank you very much!
MISC</p>

CC BY-SA 3.0
2015-07-13T14:37:28.813Z
Although I can't comment on the performance of each, I can tell you that `.find()` is optional and can be removed under all circumstances.
darylknight
CC BY-SA 3.0
2015-07-13T17:35:09.093Z
As described in [Michael's answer](http://craftcms.stackexchange.com/a/10553/45), `set` vs `find` is a false choice. `set` stores a variable for later use, while `find` reduces an ElementCriteriaModel down to an actual array. They can be used separately, or together... there is no direct conflict between the terms.
Lindsey D
<entries><variable><forloop><set>
SET versus FIND
# SET versus FIND

(Asked by: username_0 on 2015-07-13)

As I understand, I have (at least) the following two possibilities to list entries of a channel:
Possibility 1:
{% for entry in craft.entries.section('example').find() %}

Possibility 2:
{% set entries = craft.entries.section('example') %}
{% for entry in entries %}

Unfortunately, I am not experienced enough to understand the advantages and the disadvantates of these both possibilities (e.g. performance related etc.)
The only thing I see: in possibility 2 I can reuse "entries" within the same template.
I would be grateful for some further information on the differences.
Thank you very much!
MISC

**Tags:** entries, variable, forloop, set
> **Comments:**
> **username_1**: Although I can't comment on the performance of each, I can tell you that `.find()` is optional and can be removed under all circumstances.  
> **username_2**: As described in [Michael's answer](http://craftcms.stackexchange.com/a/10553/45), `set` vs `find` is a false choice. `set` stores a variable for later use, while `find` reduces an ElementCriteriaModel down to an actual array. They can be used separately, or together... there is no direct conflict between the terms.  

---

## 1 answers

### Answer by username_3 on 2015-07-13. Score: 6 | Accepted answer

You're exactly right: The advantage of using the variable is that you can re-use it throughout your template, which helps keep things DRY.
When you use craft.entries in your template, Craft serves up an ElementCriteriaModel — This is an object that knows how to query the system for a set of entries... but it doesn't actually perform that query until you either (a) call the .find() method, or (b) use the object as an interable in a loop.
In other words, the first time you try to get an Array from the ElementCriteriaModel (either by creating the array explicitly with find() or by creating it implicitly by treating it as an Array — THAT'S when Craft does the work of perofmring the query.
Unless you need to do an operation directly on the array, you don't actually need to call the .find() method. It's perfectly acceptable to let Craft do the smart thing automatically:
{% set entries = craft.entries.section(...) %}
{% for entry in entries %}
   ...
{% endfor %}

There's often a slight advantage to doing it this way, because it means if that variable never gets used (perhaps it's hidden away in an unsatisfied conditional or something), Craft never does the work of performing the query.


---

