Forum

Thread tagged as: Question, Problem

Collection of products taking 27seconds to load

Hi there,

A bit of a strange one, I have a collection of products when a user visits the list page for the first time it can take up to 27 seconds to load all the products (29 products in total). I am struggling to figure out what the cause might be. I was wondering if you could help shed some light on this?

Here is my DEBUG message

Debug Message
[84]
SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
Matched page: /en-eu/products, so not using routes.
Using master page: /templates/pages/products_eu/products.php
[1]
SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='products'
[nil]
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='_order' WHERE (idx.collectionID=25) AND ((idx.indexKey='slug' AND idx.indexValue='')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
Using template: /templates/content/products/products.html
[1]
SELECT * FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
Using template: /templates/pages/attributes/language_code.html
Using template: /templates/pages/attributes/language_code.html
Using template: /templates/pages/attributes/language_code.html
Using template: /templates/pages/attributes/language_code.html
Using template: /templates/pages/attributes/language_code.html
Using template: /templates/pages/attributes/language_code.html
Using template: /templates/pages/attributes/twitter_name.html
Using template: /templates/pages/attributes/twitter.html
Using template: /templates/pages/attributes/facebook.html
Using template: /templates/pages/attributes/seo.html
Using template: /templates/pages/attributes/body_attributes.html
[1]
SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu' OR pageSortPath='/en-eu' LIMIT 1
[12]
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-004%' AND pageDepth >=1 AND pageDepth<=3 ORDER BY pageTreePosition ASC
[1]
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
[2]
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition DESC
Using template: /templates/navigation/nav.html
[5]
Using template: /templates/navigation/subnav.html
[1]
SELECT groupID FROM perch2_navigation WHERE groupSlug='europe' LIMIT 1
[10]
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
[0]
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/en-eu/products' LIMIT 1
[10]
Using template: /templates/navigation/choose_region.html
[1]
SELECT groupID FROM perch2_navigation WHERE groupSlug='north-america' LIMIT 1
[3]
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
[0]
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/en-eu/products' LIMIT 1
[3]
Using template: /templates/navigation/choose_region.html
[1]
SELECT groupID FROM perch2_navigation WHERE groupSlug='south-america' LIMIT 1
[1]
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=4 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
[0]
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=4 AND p.pagePath='/en-eu/products' LIMIT 1
[1]
Using template: /templates/navigation/choose_region.html
[1]
SELECT groupID FROM perch2_navigation WHERE groupSlug='asia' LIMIT 1
[1]
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=5 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
[0]
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=5 AND p.pagePath='/en-eu/products' LIMIT 1
[1]
Using template: /templates/navigation/choose_region.html
[1]
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' OR pageSortPath='/en-eu/products' LIMIT 1
[1]
SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition
[1]
Using template: /templates/navigation/breadcrumbs.html
[6]
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/en-eu/products' OR regionPage='*' ORDER BY regionPage DESC
[1]
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Page Heading' AND (regionPage='/en-eu/products' OR regionPage='*')
[1]
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=288 AND idx.itemRev=1)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
[1]
Using template: /templates/content/_page_heading.html
[29]
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='_order' WHERE (idx.collectionID=25) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
[29]
Using template: /templates/content/products/products_list.html
Using template: /templates/pages/attributes/twitter_name.html
[1]
SELECT * FROM perch2_twitter_tweets WHERE tweetType='mine' AND tweetAccount='chicopee_europe' ORDER BY tweetDate DESC LIMIT 1
[32]
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1]
Using template: /templates/twitter/tweet.html
[1]
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Telephone en-eu' AND (regionPage='/en-eu/products' OR regionPage='*')
[1]
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=173 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
[1]
Using template: /templates/content/text.html
[1]
SELECT groupID FROM perch2_navigation WHERE groupSlug='footer-en-eu' LIMIT 1
[5]
SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=7 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
[0]
SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=7 AND p.pagePath='/en-eu/products' LIMIT 1
[5]
Using template: /templates/navigation/item.html
[1]
SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/segments' OR pageSortPath='/en-eu/segments' LIMIT 1
[7]
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-004-003%' AND pageDepth >=2 AND pageDepth<=3 ORDER BY pageTreePosition ASC
[1]
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
[2]
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition DESC
[6]
Using template: /templates/navigation/item.html
[1]
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Social en-eu' AND (regionPage='/en-eu/products' OR regionPage='*')
[1]
SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=170 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
[1]
Using template: /templates/content/footer/social.html
Request time: 27.1276
Process time: 27.1261
Memory: 5.1521

Here is my diagnostics report

PERCH INFORMATION

Perch Runway: 2.8.32
Production mode: Production (100)
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), perch_forms (1.8.3), collection_25 (2.8.32), collection_27 (2.8.32), perch_twitter (3.5.1)
DB driver: PDO
DB tables: perch2_backup_plans (0), perch2_backup_resources (0), perch2_backup_runs (0), perch2_blog_authors (7), perch2_blog_comments (0), perch2_blog_index (4191), perch2_blog_posts (135), perch2_blog_posts_to_tags (0), perch2_blog_sections (1), perch2_blog_tags (0), perch2_blogs (3), perch2_categories (71), perch2_category_counts (14), perch2_category_sets (6), perch2_collection_index (732002), perch2_collection_items (1639), perch2_collection_revisions (303), perch2_collections (2), perch2_content_index (12535), perch2_content_items (1952), perch2_content_regions (171), perch2_forms (4), perch2_forms_responses (126), perch2_navigation (6), perch2_navigation_pages (28), perch2_page_routes (47), perch2_page_templates (43), perch2_pages (74), perch2_resource_log (16636), perch2_resource_tags (0), perch2_resources (1895), perch2_resources_to_tags (0), perch2_scheduled_tasks (30), perch2_settings (33), perch2_twitter_scheduled_tweets (0), perch2_twitter_settings (1), perch2_twitter_tweets (1772), perch2_user_passwords (1), perch2_user_privileges (42), perch2_user_role_privileges (53), perch2_user_roles (4), perch2_users (10)
Users: 10
App runtimes:
<?php
    $apps_list = array(
        'content',
        'categories',
        'perch_blog',
        'perch_twitter',
        'perch_forms',
    );
Scheduled tasks for perch_twitter: post_tweets (1 mins), update_tweets (60 mins)
Scheduled tasks for perch_blog: delete_spam_comments (1440 mins)
Editor plug-ins: markitup
H1: c0fe4e9645faca51fb440cc5acbe78ca
L1: 20240be7944a7944e62b3cd88072c3ae
F1: 2edba60ed1f613d6dd804feb202456a2
headerColour: #e61e26
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.16: done
headerScheme: dark
update_runway_2.8.16: done
latest_version: 2.8.15
on_sale_version: 2.8.32
update_runway_2.8.19: done
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 1
content_frontend_edit: 0
perch_blog_update: 5.0.1
perch_blog_post_url: /{blogSlug}/news/{postSlug}
perch_blog_slug_format: %Y-%m-%d-{postTitle}
perch_blog_akismet_key:
perch_blog_max_spam_days: 1
perch_blog_comment_notify: 0
update_runway_2.8.23: done
perch_blog_site_name: Chicopee Solutions
logoPath: /admin/resources/1453300953_chicopee-logo.png
perch_twitter_update: 3.5
update_runway_2.8.24: done
update_runway_2.8.25: done
update_runway_2.8.28: done
update_runway_2.8.29: done
update_runway_2.8.32: done
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_SITEPATH: /var/www/html/chicopee/staging/public_html
PERCH_SCHEDULE_SECRET: 8wJeeQvIgirzvJPg
PERCH_DB_USERNAME: teamfcuk_chicope
PERCH_DB_SERVER: 87.117.230.208
PERCH_DB_DATABASE: teamfcuk_chicopee
PERCH_DB_PREFIX: perch2_
PERCH_YOUTUBE_API_KEY: AIzaSyBeSDvZackLJIyG4btIaz8qppXIDf8I0mo
PERCH_EMAIL_FROM: barry@teamfc.co.uk
PERCH_EMAIL_FROM_NAME: Barry Corrigan
PERCH_LOGINPATH: /admin
PERCH_PATH: /var/www/html/chicopee/staging/public_html/admin
PERCH_CORE: /var/www/html/chicopee/staging/public_html/admin/core
PERCH_RESFILEPATH: /var/www/html/chicopee/staging/public_html/admin/resources
PERCH_RESPATH: /admin/resources
PERCH_CLEAN_RESOURCES:
PERCH_HTML5: 1
PERCH_TZ: UTC
PERCH_DEBUG:
PERCH_PRODUCTION_MODE: 100
PERCH_RUNWAY: 1
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /var/www/html/chicopee/staging/public_html/admin/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile
HOSTING SETTINGS

PHP: 5.5.32
Zend: 2.5.0
OS: Linux
SAPI: apache2handler
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $
MySQL server: 5.5.48-log
Free disk space: 53.74 GB
Extensions: Core, date, ereg, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, session, standard, apache2handler, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, json, exif, mcrypt, memcache, mysqlnd, mysql, mysqli, PDO, pdo_mysql, pdo_sqlite, Phar, posix, shmop, SimpleXML, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xml, wddx, xmlreader, xmlwriter, xsl, zip, mhash
GD: Yes
ImageMagick: No
PHP max upload size: 256M
PHP max form post size: 128M
PHP memory limit: 128M
Total max uploadable file size: 128M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: No
HTTP_HOST: chicopee.com
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.21 Safari/537.36
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_REFERER: https://chicopee.com/admin/core/settings/diagnostics/
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8,fr;q=0.6
HTTP_COOKIE: test_status=1; region=us; cmsa=1; _ga=GA1.2.1644893137.1477308010; PHPSESSID=g4nh03duudht0qanblk5pkj8k5
HTTP_X_FORWARDED_PORT: 80
HTTP_X_FORWARDED_FOR: 86.2.230.214
HTTP_CONNECTION: close
PATH: /sbin:/usr/sbin:/bin:/usr/bin
SERVER_SIGNATURE: <address>Apache/2.2.15 (CentOS) Server at chicopee.com Port 80</address>
SERVER_SOFTWARE: Apache/2.2.15 (CentOS)
SERVER_NAME: chicopee.com
SERVER_ADDR: 95.154.250.118
SERVER_PORT: 80
REMOTE_ADDR: 87.117.230.208
DOCUMENT_ROOT: /var/www/html/chicopee/staging/public_html/
SERVER_ADMIN: bwftechs@bwf.co
SCRIPT_FILENAME: /var/www/html/chicopee/staging/public_html/admin/core/settings/diagnostics/index.php
REMOTE_PORT: 32926
GATEWAY_INTERFACE: CGI/1.1
SERVER_PROTOCOL: HTTP/1.1
REQUEST_METHOD: GET
QUERY_STRING: extended
REQUEST_URI: /admin/core/settings/diagnostics/?extended
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
PHP_SELF: /admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1477319452.417
REQUEST_TIME: 1477319452

Here is my products.php master template

<?php

    /**
      * Instead of spiltting the header layout into separte areas within the list detail if
      * statement. We have created a new if statement for the page title and passed it into the
      * header layout.
    */

    PerchSystem::set_var('home', REGION);

    /**
      * Get the post
    */

    $product = perch_collection('products', array(
        'filter' => 'slug',
        'value' => perch_get('s'),
        'skip-template' => 'true',
        'return-html'   => 'true',
    ));

    /**
      * Set up the variables
    */

    if (isset($product[0]['title'])) {

        $title  = $product['0']['title'] . " - Chicopee Solutions";

    } else {

        $title  = "Products - Chicopee Solutions";

    }

    if (isset($product[0]['sub-title'])) {

        $description = strip_tags($product['0']['sub-title']);

    } else {

        $description  = "Chicopee's foodservice towels help support your needs for back-of-house, front-of-house, and restrooms.";

    }

    if (isset($product[0]['mainimage'])) {

        $fbimage = $product[0]['mainimage'];

    } else {

        $fbimage = '/assets/img/default_fb_image.jpg';

    }

    /**
      * Use the variables in the array value
    */

    perch_page_attributes_extend(array(
        'description'    => $description,
        'og_description' => $description,
        'og_title'       => $title,
        'og_type'        => 'article',
        'sharing_image'  => $fbimage,
        'og_author'      => 'https://www.facebook.com/Chicopee.Europe',
    ));

    /**
      * Include the header & meta. You can find these in tempates/layouts/global
    */

    perch_layout('global/meta', [
        'title'=> $title,
        'language' => true,
    ]);

    perch_layout('global/header');


    /**
      * Below is the product detail page for Foodservice
      * Anything wrapped in if (perch_get('s')) { is in the detail page
    */

    if (perch_get('s')) {

        /**
          * We are using the code below to output the breadcrumbs, but becuase the collection is'nt
          * a phyiscal page within the page tree we had to pass the product title into a new
          * breadcrumbs template. We are passing the $producttitle varible to breadcrumbs template
        */

        $producttitle = perch_collection('products', array(
            'template' => 'products/_product_title.html',
            'filter' => 'slug',
            'match' => 'eq',
            'value' => perch_get('s'),
            'count' => 1
        ), true);

        PerchSystem::set_var('title', $producttitle);
        PerchSystem::set_var('home', REGION);

        perch_pages_breadcrumbs(array(
            'template'=>'product_breadcrumbs_new.html',
        ));

        echo $product['html'];

?>

<div class="menu-slideshow">

    <?php

        perch_blog_custom(array(
            'category'       => array("en-eu/case-studies"),
            'category-match' => 'all',
            'count'      => 3,
            'template'   => 'casestudy_image.html',
            'sort'       => 'postDateTime',
            'sort-order' => 'DESC',
            'blog'       => 'en-eu',
        ));
    ?>

    <div class="holder">

        <div class="imageblock__overlay-nobg-mobile">

            <div class="container">

                <div class="holder__section">

                    <div class="caption  background">
                        <h2 class="c500  beta">Case Studies</h2>

                        <?php

                            perch_blog_custom(array(
                                'category'       => array("en-eu/case-studies"),
                                'category-match' => 'all',
                                'count'          => 3,
                                'template'       => 'casestudy_title.html',
                                'sort'           => 'postDateTime',
                                'sort-order'     => 'DESC',
                                'blog'           => 'en-eu',
                            ));

                            perch_blog_custom(array(
                                'category'       => array("en-eu/case-studies"),
                                'category-match' => 'all',
                                'count'          => 3,
                                'template'       => 'casestudy_in_list.html',
                                'sort'           => 'postDateTime',
                                'sort-order'     => 'DESC',
                                'blog'           => 'en-eu',
                            ));
                        ?>

                        <a href="<?php echo '/en-eu/news/category/case-studies'; ?>" class="btn  btn__round">
                            More Case Studies <i class="icon  icon-menu"></i>
                        </a>
                    </div>

                </div>

            </div>

        </div>

    </div>

</div>

<?php

    /**
      * Include some related products.
      * Similar to what we have done on Chicopee Americas but need to come back for languages
      * Within this template is the title and sub title but language needs to change somehow
    */

    echo '<div class="section  foreground">';
    echo '<div class="container">';


        /**
          * Show Related Heading Region
        */

        perch_content_create('Related Heading', array(
            'template'   => '_page_heading.html',
            'multiple'    => false,
        ));

        perch_content_custom('Related Heading', array(
            'template'   => '_page_heading.html',
        ));


        /**
          * Show Related Products Options
        */

        perch_collection('products', [
            'template' => 'products/_related_products_v2.html',
            'filter' => 'slug',
            'value' => perch_get('s'),
        ]);


        /**
          * Show download product sheet and order sample buttons
        */

        perch_collection('products', [
            'template' => 'products/_download_product_sheet.html',
            'filter' => 'slug',
            'match' => 'eq',
            'value' => perch_get('s'),
            'count' => 1,
        ]);

    echo '</div>';
    echo '</div>';

} else {

    /**
      * Below is the product listing page for Foodservice
      * Anything wrapped in the else statement is within here
    */

    PerchSystem::set_var('home', REGION);
    perch_pages_breadcrumbs();


    echo '<div class="section  foreground">';
    echo '<div class="container  clear">';


    /**
      * Include the Page Heading section.
      * To give you an example, Its the title and sub title at the top of products listing
    */

    perch_content_create('Page Heading', array(
        'template'   => '_page_heading.html',
        'multiple'    => false,
    ));

    perch_content_custom('Page Heading', array(
        'template'   => '_page_heading.html',
    ));


    perch_layout('filters/applied-filters-eu');


    /**
      * Include the Filters Panel on the left side.
      * Template is located global/filters_left
    */

    echo '<div class="col-product__filter hide">';
        //perch_layout('filters/eu_products');
    echo '</div>';


    $pagetitle = perch_pages_title(true);
    $pagetitle = strtolower($pagetitle);

    PerchSystem::set_var('pagetitle', $pagetitle);



    // List of Yes/No filters
    $filterYesNo = array(
        'heatresistance_fs',
        'fcc_fs',
        'antibacterial_fs',
        'biodegradable_fs',
        'floor_cleaning_bc',
        'microfibre_bc',
        'biodegradable_bc',
        'heatresistance_i',
        'silicon_free_i',
        'low_lint_i',
        'low_lint_hc',
        'bacterial_removal_hc',
        'floor_cleaning_hc',
        'impregnated_hc',
        'low_lint_am',
        'solvent_compatible_am',
        'silicon_free_am',
        'negligible_static_am',
        'low_lint_as',
        'solvent_compatible_as',
        'silicon_free_as',
        'negligible_static_as',
    );

    $filterCheckboxes = array(
        'process_solvent-wiping_am',
        'process_sealer-line_am',
        'process_tack-wiping_am',
        'process_general_am',
        'process_polishing_am',
        'process_solvent-wiping_as',
        'process_sealer-line_as',
        'process_tack-wiping_as',
        'process_general_as',
        'process_polishing_as',
    );

    // List of Slider filters
    $filterSlider = array(
        'tack_level_am',
        'tack_level_as',
    );

    $filterAbsorbency = array(
        'absorbency_fs',
        'wipe_dry_fs',
        'durability_fs',
        'particle_pick_up_fs',
        'durability_bc',
        'dust_pick_up_bc',
        'absorbency_i',
        'wipe_dry_i',
        'durability_i',
        'particle_pick_up_i',
        'absorbency_hc',
        'durability_hc',
        'wipe_dry_hc',
        'particle_pick_up_hc',
        'durability_am',
        'particle_pick_up_am',
        'durability_as',
        'particle_pick_up_as',
    );


    // Create an empty array ready to add our filters to
    $filters = array();

    // Loop through checkboxes and see if it was passed in URL
    foreach ($filterCheckboxes as $key) {
        if (perch_get($key)) {
            $filters[] = array(
                'filter' => $key,
                'match'  => 'eq',
                'value'  => 1
            );
        }
    }

    // Loop through yes/no filters and see if it was passed in the URL
    foreach ($filterYesNo as $key) {
        if (perch_get($key)) {
            $filters[] = array(
                'filter' => $key,
                'match'  => 'eq',
                'value'  => ( (perch_get($key) == 'on') ? 'Yes' : 'No' )
            );
        }
    }

    // Loop through Slider filters
    foreach ($filterSlider as $key) {
        if (perch_get($key) && perch_get($key) > 1) {
            $value = 'Good';
            if (perch_get($key) == 3) {
                $value = 'Better';
            } elseif (perch_get($key) == 4) {
                $value = 'Best';
            }

            $filters[] = array(
                'filter' => $key,
                'match'  => 'eq',
                'value'  => $value
            );
        }
    }

    // Loop through Slider filters (different keys than generic ones above)
    foreach ($filterAbsorbency as $key) {
        if (perch_get($key) && perch_get($key) > 1) {
            $value = 'off';
            if (perch_get($key) == 2) {
                $value = 'Better';
            } if (perch_get($key) == 3) {
                $value = 'Best';
            }

            $filters[] = array(
                'filter' => $key,
                'match'  => 'eq',
                'value'  => $value
            );
        }
    }

    // Unique dropdown input
    if (perch_get('machine_washable_select_fs')) {
        $filters[] = array(
            'filter' => 'machine_washable_select_fs',
            'match'  => 'eq',
            'value'  => perch_get('machine_washable_select_fs')
        );
    }

    if (perch_get('machine_washable_select_bc')) {
        $filters[] = array(
            'filter' => 'machine_washable_select_bc',
            'match'  => 'eq',
            'value'  => perch_get('machine_washable_select_bc')
        );
    }

    if (perch_get('machine_washable_select_i')) {
        $filters[] = array(
            'filter' => 'machine_washable_select_i',
            'match'  => 'eq',
            'value'  => perch_get('machine_washable_select_i')
        );
    }

    if (perch_get('color_coded_cleaning_fs')) {
        $filters[] = array(
            'filter' => 'color_coded_cleaning_fs',
            'match'  => 'eq',
            'value'  => perch_get('color_coded_cleaning_fs')
        );
    }

    if (perch_get('color_coded_cleaning_hc')) {
        $filters[] = array(
            'filter' => 'color_coded_cleaning_hc',
            'match'  => 'eq',
            'value'  => perch_get('color_coded_cleaning_hc')
        );
    }

    // Unset the filters if none are used
    if (!count($filters)) {
        $filters = false;
    }

        //echo '<pre>';echo print_r($filters, true);echo '</pre>';
        //echo '<pre>';echo print_r($_SERVER, true);echo '</pre>';

        PerchSystem::set_var('home', REGION);

        echo '<div class="col-product auto no-float">';

            perch_collection('products', [
                'template' => 'products/products_list.html',
                'filter'   => $filters,
            ]);

        echo '</div>';



    echo "</div>";
    echo "</div>";



    /**
      * Include the social section for the US.
      * You can find this in tempates/layouts/global/social
      * If variable $reversed is set to TRUE
      * it will set a white background with reversed input fields
    */

    perch_layout('global/social', array(
        'reversed' => true
    ));

}

/**
  * Include the footer.
  * You can find this in tempates/layouts/global
  * If variable $reversed is set to TRUE
  * it will set a grey background
*/

perch_layout('global/footer', array(
    'reversed' => true,
    'sharing' => true,
));

?>

Here is my products list template

<perch:before>
<!-- <div class="col-product"> -->
    <ul class="product-list">
        </perch:before>

        <li class="product-list__item">
            <a href="<perch:content id="pagetitle" type="hidden" />/<perch:content id="slug" type="slug" for="title" editable="true" indelible="true" label="Slug" />" class="product-list__thumb">
                <img src="<perch:if exists="mainimage"><perch:content type="image" id="mainimage" width="305" height="223" crop="true" bucket="products" /><perch:else />/assets/img/no-image-available-314px.jpg</perch:if>" alt="<perch:content id="title" type="text" />">
            </a>
            <div class="product-list__group<perch:if not-exists="artno">  product-list__group--nomin</perch:if>">
                <h3 class="c500  delta">
                    <a href="<perch:content id="pagetitle" type="hidden" />/<perch:content id="slug" type="slug" for="title" editable="true" indelible="true" label="Slug" />" class="primary  product-list__group--link">
                        <perch:content id="title" type="text" />
                    </a>
                </h3>
                <perch:if exists="artno">
                    <span class="a350  zeta  caps">
                        SKU #S: <perch:content type="text" id="artno" />
                    </span>
                </perch:if>
            </div>
            <!-- <a href="/<perch:content id="home" type="hidden" />/product-sample?title=<perch:content id="title" />&segment=<perch:content id="segment" type="hidden" />" class="c700  zeta  caps  align-center  graychateau  product-list__btn">
                <i class="icon  icon-request-sample  beta"></i>
                Request a free sample
                <i class="icon  icon-chevron-right"></i>
            </a> -->
        </li>

        <perch:after>
    </ul>
<!-- </div> -->
</perch:after>
<perch:noresults>
    <h2 class="primary  c500  delta">There are no products matching your criteria</h2>
</perch:noresults>

Every other page is fine from what I can see

Thanks

Fishtank Creative

Fishtank Creative 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you switch to development mode so that the debug output has timings?

Here we go

Time    Δ   Debug Message
0.0403  0   [84] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
0.1512  0.1109  Matched page: /en-eu/products, so not using routes.
0.1513  0.0001  Using master page: /templates/pages/products_eu/products.php
0.1667  0.0153  [1] SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='products'
0.1864  0.0197  [nil] 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='_order' WHERE (idx.collectionID=25) AND ((idx.indexKey='slug' AND idx.indexValue='')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
0.2074  0.021   Using template: /templates/content/products/products.html
0.2256  0.0182  [1] SELECT * FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
0.2479  0.0222  Using template: /templates/pages/attributes/language_code.html
0.2484  0.0006  Using template: /templates/pages/attributes/language_code.html
0.2489  0.0004  Using template: /templates/pages/attributes/language_code.html
0.2493  0.0004  Using template: /templates/pages/attributes/language_code.html
0.2499  0.0007  Using template: /templates/pages/attributes/language_code.html
0.2504  0.0004  Using template: /templates/pages/attributes/language_code.html
0.2508  0.0004  Using template: /templates/pages/attributes/twitter_name.html
0.2512  0.0004  Using template: /templates/pages/attributes/twitter.html
0.2523  0.0011  Using template: /templates/pages/attributes/facebook.html
0.2541  0.0017  Using template: /templates/pages/attributes/seo.html
0.2549  0.0008  Using template: /templates/pages/attributes/body_attributes.html
0.2563  0.0015  [1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu' OR pageSortPath='/en-eu' LIMIT 1
0.2842  0.0278  [12] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-004%' AND pageDepth >=1 AND pageDepth<=3 ORDER BY pageTreePosition ASC
0.3219  0.0377  [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
0.3423  0.0204  [2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition DESC
0.3623  0.02    Using template: /templates/navigation/nav.html
0.3625  0.0002  [5] Using template: /templates/navigation/subnav.html
0.3765  0.0139  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='europe' LIMIT 1
0.3941  0.0176  [10] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.4148  0.0207  [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/en-eu/products' LIMIT 1
0.4342  0.0194  [10] Using template: /templates/navigation/choose_region.html
0.4437  0.0095  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='north-america' LIMIT 1
0.4617  0.018   [3] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.4829  0.0211  [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/en-eu/products' LIMIT 1
0.5022  0.0193  [3] Using template: /templates/navigation/choose_region.html
0.5056  0.0034  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='south-america' LIMIT 1
0.5259  0.0204  [1] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=4 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.5469  0.021   [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=4 AND p.pagePath='/en-eu/products' LIMIT 1
0.5662  0.0193  [1] Using template: /templates/navigation/choose_region.html
0.5677  0.0015  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='asia' LIMIT 1
0.5858  0.0181  [1] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=5 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.6066  0.0208  [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=5 AND p.pagePath='/en-eu/products' LIMIT 1
0.626   0.0195  [1] Using template: /templates/navigation/choose_region.html
0.6338  0.0078  [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' OR pageSortPath='/en-eu/products' LIMIT 1
0.6539  0.0201  [1] SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition
0.6747  0.0208  [1] Using template: /templates/navigation/breadcrumbs.html
0.6942  0.0195  [6] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/en-eu/products' OR regionPage='*' ORDER BY regionPage DESC
0.7149  0.0207  [1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Page Heading' AND (regionPage='/en-eu/products' OR regionPage='*')
0.734   0.0191  [1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=288 AND idx.itemRev=1)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
0.7543  0.0203  [1] Using template: /templates/content/_page_heading.html
0.783   0.0287  [29] 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='_order' WHERE (idx.collectionID=25) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
23.6568 22.8738 [29] Using template: /templates/content/products/products_list.html
23.7604 0.1036  Using template: /templates/pages/attributes/twitter_name.html
23.761  0.0006  [1] SELECT * FROM perch2_twitter_tweets WHERE tweetType='mine' AND tweetAccount='chicopee_europe' ORDER BY tweetDate DESC LIMIT 1
23.7855 0.0245  [32] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
23.8067 0.0211  [1] Using template: /templates/twitter/tweet.html
23.81   0.0033  [1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Telephone en-eu' AND (regionPage='/en-eu/products' OR regionPage='*')
23.8428 0.0328  [1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=173 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
23.87   0.0272  [1] Using template: /templates/content/text.html
23.8748 0.0047  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='footer-en-eu' LIMIT 1
23.9013 0.0266  [5] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=7 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
23.9377 0.0363  [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=7 AND p.pagePath='/en-eu/products' LIMIT 1
23.9587 0.0211  [5] Using template: /templates/navigation/item.html
23.9741 0.0154  [1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/segments' OR pageSortPath='/en-eu/segments' LIMIT 1
23.9946 0.0205  [7] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-004-003%' AND pageDepth >=2 AND pageDepth<=3 ORDER BY pageTreePosition ASC
24.0147 0.0201  [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
24.0341 0.0194  [2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition DESC
24.0539 0.0197  [6] Using template: /templates/navigation/item.html
24.0584 0.0045  [1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Social en-eu' AND (regionPage='/en-eu/products' OR regionPage='*')
24.0779 0.0196  [1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=170 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
24.098  0.0201  [1] Using template: /templates/content/footer/social.html
24.1007 0.0027  Request time: 24.1007
24.1008 0.0001  Process time: 24.0982
24.1008 0   Memory: 5.1542
Drew McLellan

Drew McLellan 2638 points
Perch Support

Looks like you're getting pretty bad performance out of your perch2_collection_index table. It looks like you've got quite a lot of rows in that table for the amount of content.

Are you using relationships at all? Are any of those potentially circular?

Are you indexing all fields? It's useful to add no-index="true" to any fields that you don't need to sort or filter by.

I have just looked at the table in the DB and there is over 82,000 rows.

I'm not sure what you mean when you say Are you using relationships at all? Are any of those potentially circular?

But basically here is the live product page - https://chicopee.com/en-eu/products

In the template I can select which category each product belongs to i.e Foodservice, Building Care etc.

But each Category has their own filter settings which are listed in the template.

Do I need to add no-index="true" to all fields in the product.html template except for the title and filter settings?

Drew McLellan

Drew McLellan 2638 points
Perch Support

By "are you using relationships" I mean do you have any relationships configured in your template? It's a Runway feature: https://docs.grabaperch.com/runway/relationships/

Ahh ok, Yes we have some related products displaying on the detail page, In the product.html template it outputs a list of the products from the same collection.

<!-- Start Related Content -->
<perch:related id="products_v2" collection="Products" label="Related Products" suppress="true" display-as="checkboxes" divider-before="Choose related products">
<div class="col-four">

    <a href="<perch:content id="slug" type="slug" for="title" />" class="product-list__thumb">
        <img src="<perch:if exists="mainimage"><perch:content type="image" id="mainimage" width="305" height="223" crop="true" bucket="products" /><perch:else />/assets/img/no-image-available-314px.jpg</perch:if>" alt="<perch:content id="title" type="text" />">
    </a>

    <div class="product-list__group<perch:if not-exists="artno">  product-list__group--nomin</perch:if>">

        <h3 class="c500  delta">
            <a href="<perch:content id="slug" type="slug" for="title" editable="true" indelible="true" label="Slug" />" class="primary  product-list__group--link">
                <perch:content id="title" type="text" />
            </a>
        </h3>

        <perch:if exists="artno">
            <span class="a350  zeta  caps">
                SKU #S: <perch:content type="text" id="artno" />
            </span>
        </perch:if>

    </div>

</div>
</perch:related>
<!-- Stop Related Content -->

The content editor can choose some products that relates to the current one in view. Would this be affecting the list page load time? If so how do I get around this?

Thanks Barry

Drew McLellan

Drew McLellan 2638 points
Perch Support

So is the relationship back against itself? I think that would cause your problems.

When an item is indexed, the related items are indexed against it. By relating something to itself, you end up with a circular reference.

Can you add no-index="true" onto your perch:related tag? If you then click Save a few times you should see the number of rows in that index table drop dramatically. (I think!)

Unfortunately, that didn't solve it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

How many rows do you have now?

Previously I mentioned 82,000 rows but this was meant to be 820,000 rows. Now its 847,029 rows (But we have added a few new products this week)

I must mention that we have two collections in place one that showcases European Products and One that showcases US products (all completely separate)

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think it's too soon to say that hasn't had an impact. Provided this isn't a live site, you should be able to truncate the perch2_collection_index table and then save content to rebuild it.

This is a live site. So if I empty this table will it get rebuilt by logging into the CMS again? Or will it delete everything?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, don't do that on your live site.

I'd suggest importing the database to your dev environment and testing there. The index is generated when content is saved, nothing to do with logging in.

Ok so have an update on this. I removed the related products section from the template (HTML above). Now the products are loading pretty fast.

The amount of rows on the perch2_collection_index table is still 834,000 rows though.

Time    Δ   Debug Message
0.3179  0   [84] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
0.426   0.1081  Matched page: /en-eu/products, so not using routes.
0.4261  0.0002  Using master page: /templates/pages/products_eu/products.php
0.4272  0.001   [1] SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='products'
0.4456  0.0184  [nil] 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='_order' WHERE (idx.collectionID=25) AND ((idx.indexKey='slug' AND idx.indexValue='')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
0.4661  0.0205  Using template: /templates/content/products/products.html
0.4767  0.0106  [1] SELECT * FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
0.4946  0.0179  Using template: /templates/pages/attributes/language_code.html
0.4952  0.0006  Using template: /templates/pages/attributes/language_code.html
0.4957  0.0005  Using template: /templates/pages/attributes/language_code.html
0.4961  0.0004  Using template: /templates/pages/attributes/language_code.html
0.4967  0.0006  Using template: /templates/pages/attributes/language_code.html
0.4972  0.0005  Using template: /templates/pages/attributes/language_code.html
0.4976  0.0004  Using template: /templates/pages/attributes/twitter_name.html
0.4981  0.0005  Using template: /templates/pages/attributes/twitter.html
0.4992  0.0011  Using template: /templates/pages/attributes/facebook.html
0.5009  0.0017  Using template: /templates/pages/attributes/seo.html
0.5017  0.0007  Using template: /templates/pages/attributes/body_attributes.html
0.5034  0.0017  [1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu' OR pageSortPath='/en-eu' LIMIT 1
0.5292  0.0259  [12] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-004%' AND pageDepth >=1 AND pageDepth<=3 ORDER BY pageTreePosition ASC
0.6021  0.0729  [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
0.6263  0.0241  [2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition DESC
0.6438  0.0175  Using template: /templates/navigation/nav.html
0.6441  0.0003  [5] Using template: /templates/navigation/subnav.html
0.6626  0.0185  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='europe' LIMIT 1
0.6844  0.0218  [10] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=2 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.7064  0.022   [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=2 AND p.pagePath='/en-eu/products' LIMIT 1
0.7225  0.0161  [10] Using template: /templates/navigation/choose_region.html
0.7348  0.0122  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='north-america' LIMIT 1
0.7505  0.0158  [3] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=3 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.7679  0.0174  [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=3 AND p.pagePath='/en-eu/products' LIMIT 1
0.7872  0.0193  [3] Using template: /templates/navigation/choose_region.html
0.7907  0.0035  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='south-america' LIMIT 1
0.807   0.0164  [1] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=4 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.8271  0.02    [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=4 AND p.pagePath='/en-eu/products' LIMIT 1
0.8466  0.0195  [1] Using template: /templates/navigation/choose_region.html
0.8481  0.0015  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='asia' LIMIT 1
0.8667  0.0186  [1] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=5 AND p.pageNew=0 AND np.pageDepth >=0 AND np.pageDepth<=1 ORDER BY np.pageTreePosition ASC
0.8837  0.017   [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=5 AND p.pagePath='/en-eu/products' LIMIT 1
0.9028  0.0191  [1] Using template: /templates/navigation/choose_region.html
0.9105  0.0077  [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' OR pageSortPath='/en-eu/products' LIMIT 1
0.9269  0.0164  [1] SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition
0.9435  0.0167  [1] Using template: /templates/navigation/breadcrumbs.html
0.9449  0.0013  [6] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/en-eu/products' OR regionPage='*' ORDER BY regionPage DESC
0.9635  0.0186  [1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Page Heading' AND (regionPage='/en-eu/products' OR regionPage='*')
0.9831  0.0196  [1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=288 AND idx.itemRev=1)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
0.9997  0.0166  [1] Using template: /templates/content/_page_heading.html
1.0026  0.0029  [35] 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='_order' WHERE (idx.collectionID=25) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
1.1663  0.1638  [35] Using template: /templates/content/products/products_list.html
1.2407  0.0744  Using template: /templates/pages/attributes/twitter_name.html
1.2413  0.0006  [1] SELECT * FROM perch2_twitter_tweets WHERE tweetType='mine' AND tweetAccount='chicopee_europe' ORDER BY tweetDate DESC LIMIT 1
1.2748  0.0335  [32] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
1.3114  0.0367  [1] Using template: /templates/twitter/tweet.html
1.316   0.0045  [1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Telephone en-eu' AND (regionPage='/en-eu/products' OR regionPage='*')
1.354   0.038   [1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=173 AND idx.itemRev=7)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
1.3715  0.0175  [1] Using template: /templates/content/text.html
1.3733  0.0018  [1] SELECT groupID FROM perch2_navigation WHERE groupSlug='footer-en-eu' LIMIT 1
1.3918  0.0185  [5] SELECT np.pageID, np.pageParentID, p.pagePath, p.pageTitle, p.pageNavText, p.pageNew, p.pageOrder, np.pageDepth, p.pageSortPath, np.pageTreePosition, p.pageAccessTags, p.pageAttributes FROM perch2_navigation_pages np, perch2_pages p WHERE p.pageID=np.pageID AND np.groupID=7 AND p.pageNew=0 ORDER BY np.pageTreePosition ASC
1.412   0.0202  [0] SELECT np.pageTreePosition FROM perch2_pages p, perch2_navigation_pages np WHERE np.pageID=p.pageID AND np.groupID=7 AND p.pagePath='/en-eu/products' LIMIT 1
1.4338  0.0218  [5] Using template: /templates/navigation/item.html
1.4379  0.0041  [1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/segments' OR pageSortPath='/en-eu/segments' LIMIT 1
1.4553  0.0174  [7] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-004-003%' AND pageDepth >=2 AND pageDepth<=3 ORDER BY pageTreePosition ASC
1.472   0.0167  [1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/en-eu/products' LIMIT 1
1.4912  0.0192  [2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-004-001', '000-004', '000') ORDER BY pageTreePosition DESC
1.5112  0.02    [6] Using template: /templates/navigation/item.html
1.5158  0.0045  [1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Social en-eu' AND (regionPage='/en-eu/products' OR regionPage='*')
1.5434  0.0276  [1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=170 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
1.5653  0.0219  [1] Using template: /templates/content/footer/social.html
1.5694  0.004   Request time: 1.5693
1.5694  0.0001  Process time: 1.2905
1.5695  0   Memory: 5.4799
Drew McLellan

Drew McLellan 2638 points
Perch Support

I'd expect items to drop out of perch2_collection_index over time as they are removed from the undo history stack.