Forum

Thread tagged as: Question, Problem

collections list page is slow

I have about 20-30 entries in a collection, and below is my code.

$data = perch_collection('Celebrities', [
        'skip-template' => true,
        'sort-order' =>'DESC'
    ]); 

it is taking about 10-12 secs for the page to load. It use to load fast when I had fewer collections. Please see debug screenshot here

https://www.dropbox.com/s/go0lzke7aiw3ilj/Screen%20Shot%202016-08-15%20at%208.59.50%20PM.png?dl=0

How can I speed it up?

sawan ruparel

sawan ruparel 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

We need to see the template you are using and your Diagnostics Report with each post to the forum.

Sorry, please find below.

Perch Runway: 2.8.29, PHP: 5.6.24, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), jw_activity_log (1.0.1), perch_blog (5.0), collection_2 (2.8.29), ketterus_dashboard (1), collection_3 (2.8.29), perch_forms (1.8.3), instagram (2.1), perch_shop_orders (1.0), perch_shop_products (1.0), perch_shop (1.0), storelocator (2.1), styles/?page=admin/styles_list.php (2.1), perch_members (1.5), perch_mailchimp (3.0.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', 'perch_mailchimp', 'perch_forms', 'perch_blog', 'instagram', 'jw_activity_log', 'storelocator', 'customplugin', );
PERCH_LOGINPATH: /content
PERCH_PATH: /var/www/html/Somesite.com/content
PERCH_CORE: /var/www/html/Somesite.com/content/core
PERCH_RESFILEPATH: /var/www/html/Somesite.com/content/resources
Image manipulation: GD
PHP limits: Max upload 15M, Max POST 8M, Memory: 128M, Total max file upload: 8M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: dev.Somesite.com
DOCUMENT_ROOT: /var/www/html/Somesite.com
REQUEST_URI: /content/core/settings/diagnostics/
SCRIPT_NAME: /content/core/settings/diagnostics/index.php

this is how my template page looks like

 <?php
$data = perch_collection('Fashion Week', [
        'skip-template' => true,
        'sort-order' =>'DESC'
    ]); 
foreach ($data as $k=>$d){
    echo '<li class="product"><a title="'.$d['fashion_week_name'].'" href="/fashion-week/'.$d['slug'].'" event="'.$d['_id'].'"><img alt="'.$d['fashion_week_name'].'" src="'.$d['fw_image_list'].'" width="270" height="425"></a><div class="labelrow text-center" style="    opacity: .8;font-size: 11px;"><div class="left"><div class="category-product-title" style="line-height: 12px;font-size: 11px;"><a title="'.$d['fashion_week_name'].'" href="/celebrities/'.$d['slug'].'" event="'.$d['_id'].'">'.$d['fashion_week_name'].'</a></div><div class="category-social-icons-list">';
    perch_layout('global/gigya', array('id'=>$k,'title'=>$d['fashion_week_name'],'image'=>$d['fw_image_list'],'link'=>'/celebrities/'.$d['slug']));
    echo '</div></div><div class="right"></div></div></li>';
}
?>
Rachel Andrew

Rachel Andrew 394 points
Perch Support

That doesn't look like your template. Can we see your template please?

Oh, I am sorry. here you go

<perch:content id="fashion_week_name" type="text" label="Fashion Week Name" />
<perch:content id="slug" type="slug" for="fashion_week_name" editable="true" indelible="true" label="URL Path" help="If you leave blank will fill up automatically" />
<perch:content id="fw_image_list" type="image" label="Fashion Week Image (List page)" width="270" height="425" crop="true" bucket="fashionweek" help="270 x 360 px" />


<source src="<perch:content id="mp4video" bucket="videos" type="text" size="xl" label="MP4 Video URL" default="https://s3.amazonaws.com/resourcesvideo.sherrihill.com/" help="Please upload the video <a href='https://console.aws.amazon.com/s3/home?region=us-east-1#&bucket=resourcesvideo.sherrihill.com&prefix='>here</a> https://console.aws.amazon.com/s3/home?region=us-east-1#&bucket=resourcesvideo.sherrihill.com&prefix= and copy the URL"  />" type="video/mp4">
<source src="<perch:content id="webmvideo" bucket="videos" type="text" size="xl" label="WEBM Video URL" default="https://s3.amazonaws.com/resourcesvideo.sherrihill.com/" help="Please upload the video here https://console.aws.amazon.com/s3/home?region=us-east-1#&bucket=resourcesvideo.sherrihill.com&prefix= and copy the URL"  />" type="video/webm">
<source src="<perch:content id="oggvideo" bucket="videos" type="text" size="xl" label="OGG Video URL" default="https://s3.amazonaws.com/resourcesvideo.sherrihill.com/" help="Please upload the video here https://console.aws.amazon.com/s3/home?region=us-east-1#&bucket=resourcesvideo.sherrihill.com&prefix= and copy the URL"  />" type="video/ogg">

<perch:blocks>
    <perch:block label="Tabs" type="tabs_content">
        <perch:content id="tab_label" type="text" label="Table Title" required="true" />
        <perch:repeater label="Content">
            <perch:content id="image_caption" type="text" size="xl" label="Image Caption" />
            <perch:content id="image_src" type="image" label="Image" bucket="fashionweek" />
            <perch:content id="video_time" type="text" label="Time" size="m" placeholder="00:00:00" />
        </perch:repeater>
        <perch:blocks>
            <perch:block label="Images" type="images">
            <perch:repeater label="Images">
                <perch:content id="image_caption" type="text" size="xl" label="Image Caption" />
                <perch:content id="image_src" type="image" label="Image" bucket="fashionweek" />
            </perch:repeater>
            </perch:block>
        </perch:blocks>

    </perch:block>
</perch:blocks>

Drew McLellan

Drew McLellan 2638 points
Perch Support

The debug shows the collection query executing quite quickly - the delay looks like it's on your query of the language table.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you want to get some more timing points, you can do this:

<?php
PerchUtil::mark('Collection start');
$data = perch_collection('Fashion Week', [
        'skip-template' => true,
        'sort-order' =>'DESC'
    ]); 
PerchUtil::mark('Collection done');
PerchUtil::mark('For loop start');
foreach ($data as $k=>$d){
    echo '<li class="product"><a title="'.$d['fashion_week_name'].'" href="/fashion-week/'.$d['slug'].'" event="'.$d['_id'].'"><img alt="'.$d['fashion_week_name'].'" src="'.$d['fw_image_list'].'" width="270" height="425"></a><div class="labelrow text-center" style="    opacity: .8;font-size: 11px;"><div class="left"><div class="category-product-title" style="line-height: 12px;font-size: 11px;"><a title="'.$d['fashion_week_name'].'" href="/celebrities/'.$d['slug'].'" event="'.$d['_id'].'">'.$d['fashion_week_name'].'</a></div><div class="category-social-icons-list">';
    perch_layout('global/gigya', array('id'=>$k,'title'=>$d['fashion_week_name'],'image'=>$d['fw_image_list'],'link'=>'/celebrities/'.$d['slug']));
    echo '</div></div><div class="right"></div></div></li>';
}
PerchUtil::mark('For loop done');
?>

Drew,

thank you so very much for staying with me. this is causing lot of problems. We never had that issue until recently when client started putting in all the live data. We are so close to tight deadline for launching it :-(

anyway, here is the screenshot of debug info

https://snag.gy/75ceJo.jpg

Appreciate all your help

Actually, I may have some good news.

after looking at the times I realize, that it was trying to parse collection template and then doing the loop thing. so I created a new template for listing only, and it seems to be fast on one of the collection.

I am now trying another one, I am sure it will work out, will post results once I have them.

Kool.

Something worth knowing. I could speed up both slow pages by using a special template for listing the collection items.

By using 'skip-template', it was getting all details for each collection item, and that was causing too much time, since each of my collection has about 150-300 nested images,

If I use template, somehow it is only getting the required details and speed is back up to what we love perch for :-)

thank you, and sorry for putting up with me