<p>I used to have the same issue then I started using Eager Loading Element. It allows you to speed up your craft cms templates by fetching matrix from the database more efficiently. </p>

<p>You can refer to this <a href="https://www.google.co.nz/amp/s/nystudio107.com/blog/speed-up-your-craft-cms-templates-with-eager-loading/amp" rel="nofollow noreferrer">link</a> which might help you for further understanding of Eager Loading. </p>

CC BY-SA 4.0
2019-05-02T20:34:49.040Z
Thanks for the reply, eager loading helps marginally. After further investigation my issue that was slowing it down on the first load was the image transform generating the images. It would be good if these could be generated from the control panel.
Pedro
CC BY-SA 4.0
2019-05-02T10:39:16.487Z
2019-05-02T10:39:16.487Z
Priti Rathod
<p>I am fairly new to Craft CMS but have a good understanding of it. I have a page that has a Matrix field to display staff photos and their roles.</p>

<p>On the initial load of this page, it is slow, it takes nearly 22 seconds. It is only 1meg of data.</p>

<p>Some stats on the initial load:
• DB queries 200
• 22 seconds to load</p>

<p>Once it has been loaded into the cache it is much better:
• DB queries 165
• 1.6 seconds to load</p>

<p>I have tried eager loading the image field and image transform with no speed increase:</p>

<pre><code>{% set teamMembers = entry.teamMembers.with([
        ['blockType:image', {
            withTransforms: ['teamMemberSmall']
        }]
    ]).all() 
%}
</code></pre>

<p>It's not a huge amount of data so I would have thought this could be much faster. Based on the profiling it looks like it is the asset transform generation that is killing the page. Any tips or tricks I can do to get that initial page load faster? Can the assets be pre-generated?</p>

<p>Server stats:</p>

<ul>
<li>PHP 7.2</li>
<li>MYSQL 5.5</li>
<li>Memory Limit 256mb</li>
</ul>

<matrix><cache><speed><optimization>
Page with Matrix field slow to load
# Page with Matrix field slow to load

(Asked by: username_0 on 2019-05-01)

I am fairly new to Craft CMS but have a good understanding of it. I have a page that has a Matrix field to display staff photos and their roles.
On the initial load of this page, it is slow, it takes nearly 22 seconds. It is only 1meg of data.
Some stats on the initial load:
• DB queries 200
• 22 seconds to load
Once it has been loaded into the cache it is much better:
• DB queries 165
• 1.6 seconds to load
I have tried eager loading the image field and image transform with no speed increase:
{% set teamMembers = entry.teamMembers.with([
        ['blockType:image', {
            withTransforms: ['teamMemberSmall']
        }]
    ]).all() 
%}

It's not a huge amount of data so I would have thought this could be much faster. Based on the profiling it looks like it is the asset transform generation that is killing the page. Any tips or tricks I can do to get that initial page load faster? Can the assets be pre-generated?
Server stats:

PHP 7.2
MYSQL 5.5
Memory Limit 256mb

**Tags:** matrix, cache, speed, optimization


---

## 1 answers

### Answer by username_1 on 2019-05-02. Score: 1

I used to have the same issue then I started using Eager Loading Element. It allows you to speed up your craft cms templates by fetching matrix from the database more efficiently.

You can refer to this [link](https://www.google.co.nz/amp/s/nystudio107.com/blog/speed-up-your-craft-cms-templates-with-eager-loading/amp) which might help you for further understanding of Eager Loading.

> **Comments:**
> **username_0**: Thanks for the reply, eager loading helps marginally. After further investigation my issue that was slowing it down on the first load was the image transform generating the images. It would be good if these could be generated from the control panel.  

---

