We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22656
    • 121 Posts
    Just been developing some pages within modX Revo, on average pages took around a second (1 - 1.3secs) to process & render (this included making calls to an external database and then looping through big recordsets whilst also making subsequent subquery calls on each iteration).

    After including a simple getResources call (search by tag), the execution time extended to 1.8-2.1 secs, that is almost double to what I had before. Could someone offer any insight into why this is so and how i can remedy it?

    All I am doing is using tagging to pull in specific content from a particular folder, so:

    [[!getResourcesTag?
      &element=`getResources`
      &elementClass=`modSnippet`
      &tpl=`travelguide_slide`
      &hideContainers=`0`
      &parents=`3085`
      &limit=`2`
      &includeContent=`1`
      &tvFilters=`tags==%[[!current_destination]]%`
    ]]


    &tpl=
    <div style="padding:20px;">
        <h2 class="title"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h2>
        <p class="post-info">Posted by [[+createdby:userinfo=`fullname`]]
     [[+tv.tags:notempty=` | <span class="tags">Tags:
    [[!tolinks? &items=`[[+tv.tags]]` &key=`tag` &target=`1`]]
    </span>`]]</p>
        <div class="entry">
          <p>[[+content]]... <a href="/[[~[[+id]]]]" class="readmore"> Read more </a></p>
    <div class="clear"></div>
        </div>
        <p class="postmeta">
          <span class="links">
    | <a href="[[~[[+id]]]]#comments" class="comments">
        Comments ([[!QuipCount? &thread=`[[!getParent? &parent=`[[*parent]]` &pagetitle=[[*pagetitle]] ]]-[[+id]]`]])
      </a>
    | <span class="date">[[+publishedon:strtotime:date=`%b %d, %Y`]]</span>
          </span>
        </p>
    </div>
    <br />


    taking quip comments out of the equation halves the getresources call exec time by 50%:

    &tpl=
    <div style="padding:20px;">
        <h2 class="title"><a href="[[~[[+id]]]]">[[+pagetitle]]</a></h2>
        <p class="post-info">Posted by [[+createdby:userinfo=`fullname`]]
     [[+tv.tags:notempty=` | <span class="tags">Tags:
    [[!tolinks? &items=`[[+tv.tags]]` &key=`tag` &target=`1`]]
    </span>`]]</p>
        <div class="entry">
          <p>[[+content]]... <a href="/[[~[[+id]]]]" class="readmore"> Read more </a></p>
    <div class="clear"></div>
        </div>
    </div>
    <br />
      • 33968
      • 863 Posts
      I think you said it already:
      taking quip comments out of the equation halves the getresources call exec time by 50%:
      You have a lot of uncached - and nested - snippet calls in there. All those uncached snippet calls inside tpl chunks have to be executed for every item in the getResourcesTag loop. That's slow and really inefficient.

      What do [ [!current_destination]] and [ [!tolinks]] do?

      If there's anything in there you can get away with caching, do it. You might also look at coding this up in a custom snippet to avoid all the nesting, but that's obviously going to be more work.
        • 22656
        • 121 Posts
        Problem is the getresources call is placed on one page which is shared across different URLs using htaccess rewrites. This means I have to have it uncached otherwise correct content is not being pulled in for every URL.

        current_destination is a simple snippet checking querystring values:

        if ($_GET['town']!='')return my_ucwords($_GET['town']);
        elseif ($_GET['city']!='')return my_ucwords($_GET['city']);
        elseif ($_GET['subregion']!='')return my_ucwords($_GET['subregion']);
        elseif ($_GET['region']!='')return my_ucwords($_GET['region']);
        else return my_ucwords($_GET['country']);


        toLinks is part of tagLister snippet, i could do without it here tbh, so im going to take it out.
          • 22656
          • 121 Posts
          Yup, took tolinks]] out, as well as QuipCount]], I am back to ~1.3 secs exec time. [ed. note: papachumba last edited this post 14 years, 10 months ago.]