title: SQL query executed several times instead of one
body: <p>I have an identical SQL query is executed several times while I call it only once in my code.</p>
  <p>This involves retrieving all of a user's notifications to display them on any page of my site, in the navbar. So I have a callable Service from Twig with a <em>notifications()</em> function :</p>
  <pre><code>public function notifications()
  {
      $user   = $this-&gt;tokenStorage-&gt;getToken()-&gt;getUser();
      $result = $this-&gt;em-&gt;getRepository(Notification::class)-&gt;getLastNotifications($user, 20);
  
      return $result;
  }
  </code></pre>
  <p>And in the Symfony profiler, I see that this request is called 3 times...</p>
  <p><a href="https://i.stack.imgur.com/gTcbd.png" rel="nofollow noreferrer">Symfony Profiler Screenshot</a></p>
  <p>At Twig level, I get the result of the function like this:</p>
  <pre><code>{% for notification in global_data.notifications %}
  {% endfor %} 
  </code></pre>
  <p>Can you tell me why Symfony executes this request 3 times?</p>
  <p>Thanks</p>