Forum
Collection Template Slow Load
Hello,
For some reason one of my collections is loading the template noticeably slow, I've identified the template as the slow load from debug.
Is there anything I can do to see why it's loading so slow? (This is the only template in the entire site thats doing this).
Debug & Template Below
Time Δ Debug Message - Perch Runway 3.0.3
0.0492 0 [86] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
0.0624 0.0132 Matched page: /news/case-studies, so not using routes.
0.0625 0.0001 Using master page: /templates/pages/news/case_studies.php
0.0677 0.0052 [1] SELECT * FROM perch2_pages WHERE pagePath='/news/case-studies' LIMIT 1
0.0696 0.0019 Using template: /templates/pages/attributes/default.html
0.0698 0.0002 Using sub-template: /templates/pages/attributes/plugins.html
0.0749 0.0051 [70] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
0.0796 0.0046 Using template: /templates/forms/filter.html
0.0829 0.0033 [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/news/case-studies' OR pageSortPath='/news/case-studies' LIMIT 1
0.0835 0.0006 [2] SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-005-001', '000-005', '000') ORDER BY pageTreePosition
0.0842 0.0008 [2] Using template: /templates/navigation/breadcrumbs.html
0.0853 0.0011 [1] SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='Case Studies'
0.086 0.0007 [31] SELECT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch2_collection_index idx JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='date' WHERE (idx.collectionID=7) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval DESC
0.8971 0.8111 [31] Using template: /templates/content/_ld/case_studies/list.html // THIS IS THE PROBLEM
0.9175 0.0204 Using template: /templates/pages/attributes/footer_plugins.html
0.9193 0.0018 [1] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/news/case-studies' OR regionPage='*' ORDER BY regionPage DESC
0.9205 0.0012 Request time: 0.9205
0.9205 0 Process time: 0.9191
0.9206 0 Memory: 4.6985
<perch:before>
<div class="full-width">
<div class="row">
</perch:before>
<div class="four columns">
<a href="/news/case-studies/<perch:content id="url_slug" />">
<figure class="photo-block">
<img src="<perch:content id="list_image" type="image" label="List Image" width="800" height="600" crop="true" />">
<figcaption>
<h2><perch:content id="title" /></h2>
<perch:content id="text" chars="100" type="textarea" append="..." />
</figcaption>
</figure>
</a>
</div>
<perch:every count="3">
</div>
<div class="row">
</perch:every>
<perch:after>
</div>
</div>
</perch:after>
It's the database query rather than the template. Can you show us your diagnostics?
Ahh ok, it's on dev at the moment. Perhaps it something to do with that but it wasn't doing so before I made template changes. I did at perch:related tags which understandably I could see why this would increase it.
Diagnostics below
Have you checked that you've not created a circular relationship? You seem to have a lot of index entries compared to the number of items.
Hmm it wasn't a circular relationship but I've removed the related tags and re saved all collection items to test and that's halved the time.
Is there a way to clean up the collection index, as nearly 10k seems a bit high
Are you indexing all fields? Do you need to? The only fields that are required for indexing are those you want to sort or filter by.
It looks like it, I wasn't aware you can specify what gets indexed. How do I change that?
If there's content you don't want to index, you can add
no-index="true"
to its content tag in the master template.Ah that would be where it's going wrong. Using Perch for years and seen that.
Thanks Drew, I should be able to fix this now