<p>You could <a href="https://docs.craftcms.com/v3/dev/eager-loading-elements.html" rel="nofollow noreferrer">eager load</a> a little more to speed things up. Especially your <code>eventVenueName</code> and <code>eventCity</code></p>

<p>For your query, try:</p>

<pre class="lang-twig prettyprint-override"><code>{% set entries = craft.entries ({
        section: 'events',
        limit: '30',
        order: 'postDate desc',
        with: [
            'eventMediaTile',
            'eventVenueName',
            'eventCity'
        ],
        relatedTo: category }) %}
</code></pre>

<p>Then in your <code>_card</code> do:</p>

<pre class="lang-twig prettyprint-override"><code>&lt;a href="{{ entry.url }}" title="{{ entry.title }} Tickets" class="card card-md waves-effect waves-light" aria-label="{{ entry.title }} Tickets"&gt;
    {% if entry.eventPercentageSaving &gt; 0 %}
        &lt;div class="corner-ribbon top-right"&gt;{{ entry.eventPercentageSaving }}% Off&lt;/div&gt;
    {% endif %}

    {% set cardImage = entry.eventMediaTile[0] ?? null %}
    {% if cardImage %}
        &lt;div class="card-image"&gt;
            &lt;img src="{{ cardImage.geturl }}" alt="{{ entry.title }} Preview Image"&gt;
        &lt;/div&gt;
    {% endif %}

    &lt;div class="card-content"&gt;
        &lt;h3 class="card-title"&gt;{{ entry.title }}&lt;/h3&gt;
        &lt;p&gt;{{ entry.eventVenueName[0].title ?? 'N/A' }}, {{ entry.eventCity[0].title ?? 'N/A' }}&lt;/p&gt;
        &lt;div class="btn"&gt;From £{{ entry.eventMinimumPrice }}&lt;/div&gt;
    &lt;/div&gt;
&lt;/a&gt;
</code></pre>

<p>If you turn the debug toolbar on your front-end (under your user's preferences) before implementing, and look at the query count, you should see a significant drop. </p>

<p>If this isn't enough, you could <a href="https://docs.craftcms.com/v3/dev/tags/cache.html" rel="nofollow noreferrer">start caching</a>. Andrew has <a href="https://nystudio107.com/blog/the-craft-cache-tag-in-depth" rel="nofollow noreferrer">a great article</a> on this.</p>

CC BY-SA 4.0
2020-03-13T13:52:13.507Z
2020-03-13T13:52:13.507Z
Oli
<p>I have the following category <a href="https://www.ticketstoday.co.uk/theatre" rel="nofollow noreferrer">https://www.ticketstoday.co.uk/theatre</a> which has around 600/700 Entries, this is paginated at 30x Entries a page. Unfortunately, it's loading rather slowly. It's not a huge entry count so I'm unsure what's happening.</p>

<pre><code>  {% set entries = craft.entries ({
          section: 'events',
          limit: '30',
          order: 'postDate desc',
          with: ['eventMediaTile'],
          relatedTo: category
      }) %}

  {% paginate entries as pageInfo, pageEntries %}
  {% do seomatic.helper.paginate(pageInfo) %}

  {% for entry in pageEntries %}
    {% include '_card' %}
  {% endfor %}
</code></pre>

<p>Is there anything at all I can do to speed up the query, or, is it a limitation of Craft?</p>

<blockquote>
  <p>Added Card Template below</p>
</blockquote>

<pre><code>&lt;a href="{{ entry.url }}" title="{{ entry.title }} Tickets" class="card card-md waves-effect waves-light" aria-label="{{ entry.title }} Tickets"&gt;
{% if entry.eventPercentageSaving &gt; 0 %}
  &lt;div class="corner-ribbon top-right"&gt;{{ entry.eventPercentageSaving }}% Off&lt;/div&gt;
{% endif %}
{% for asset in entry.eventMediaTile %}
  &lt;div class="card-image"&gt;
    &lt;img src="{{ asset.geturl }}" alt="{{ entry.title }} Preview Image"&gt;
  &lt;/div&gt;
{% endfor %}

&lt;div class="card-content"&gt;
  &lt;h3 class="card-title"&gt;{{ entry.title }}&lt;/h3&gt;
  &lt;p&gt;{{ entry.eventVenueName.one().title ?? 'N/A' }}, {{ entry.eventCity.one().title ?? 'N/A' }}&lt;/p&gt;
  &lt;div class="btn"&gt;From £{{ entry.eventMinimumPrice }}&lt;/div&gt;
&lt;/div&gt;

&lt;/a&gt;
</code></pre>

CC BY-SA 4.0
2020-03-13T08:58:51.480Z
Could you add the code you have in `{% include '_card' %}` to your question?
Oli
CC BY-SA 4.0
2020-03-13T12:45:31.847Z
Added the partial @Oli
JMKelley
<templating><performance>
Slow Category Loading
# Slow Category Loading

(Asked by: username_0 on 2020-03-12)

I have the following category https://www.ticketstoday.co.uk/theatre which has around 600/700 Entries, this is paginated at 30x Entries a page. Unfortunately, it's loading rather slowly. It's not a huge entry count so I'm unsure what's happening.
  {% set entries = craft.entries ({
          section: 'events',
          limit: '30',
          order: 'postDate desc',
          with: ['eventMediaTile'],
          relatedTo: category
      }) %}

  {% paginate entries as pageInfo, pageEntries %}
  {% do seomatic.helper.paginate(pageInfo) %}

  {% for entry in pageEntries %}
    {% include '_card' %}
  {% endfor %}

Is there anything at all I can do to speed up the query, or, is it a limitation of Craft?

Added Card Template below


{% if entry.eventPercentageSaving > 0 %}
  {{ entry.eventPercentageSaving }}% Off
{% endif %}
{% for asset in entry.eventMediaTile %}
  
    
  
{% endfor %}


  {{ entry.title }}
  {{ entry.eventVenueName.one().title ?? 'N/A' }}, {{ entry.eventCity.one().title ?? 'N/A' }}
  From £{{ entry.eventMinimumPrice }}

**Tags:** templating, performance

> **Comments:**
> **username_1**: Could you add the code you have in `{% include '_card' %}` to your question?  
> **username_0**: Added the partial @username_1  

---

## 1 answers

### Answer by username_1 on 2020-03-13. Score: 2 | Accepted answer

You could eager load a little more to speed things up. Especially your eventVenueName and eventCity
For your query, try:
{% set entries = craft.entries ({
        section: 'events',
        limit: '30',
        order: 'postDate desc',
        with: [
            'eventMediaTile',
            'eventVenueName',
            'eventCity'
        ],
        relatedTo: category }) %}

Then in your _card do:

    {% if entry.eventPercentageSaving > 0 %}
        {{ entry.eventPercentageSaving }}% Off
    {% endif %}

    {% set cardImage = entry.eventMediaTile[0] ?? null %}
    {% if cardImage %}
        
            
        
    {% endif %}

    
        {{ entry.title }}
        {{ entry.eventVenueName[0].title ?? 'N/A' }}, {{ entry.eventCity[0].title ?? 'N/A' }}
        From £{{ entry.eventMinimumPrice }}
    


If you turn the debug toolbar on your front-end (under your user's preferences) before implementing, and look at the query count, you should see a significant drop. 
If this isn't enough, you could start caching. Andrew has a great article on this.


---

