We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi guys,

    Has anyone else noticed page load lag on pages that are using getResources to fetch and render page content? I am noticing lag periods of between 2 and 5 seconds and it’s consistent across browsers and internet connections so nothing to do with that... Has anyone else noticed this?

    Is there anything than can be sorted in the snippet to reduce overheads? I love gR and think its a fab resource meaning need for just 1 snippet rather than Ditto and WayFinder! Fingers crossed we can find a resolution to make it perform as well as it is functional!

    P.S. I have already gone through and add &depth=1 to all calls to reduce the default looking into x5 levels but that does not seem to have made much difference...



    Cheers,

    dubbs.
    • Please show us your call, and tell us how many Resources it’s retrieving. Also, are there any Plugins running or other Snippets on the page?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 8168
        • 1,118 Posts
        Thanks Ryan,

        For an example page that has a fair amount of lag we have the calls as below:

        [[!getResources? &parents=`10` &limit=`1000` &tpl=`portfolioAccordionMenuLiTpl` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &sortby=`publishedon` &hideContainers=`1` &depth=`1` ]]
        


        [[!getResources? &parents=`75` &limit=`7` &tpl=`portfolioindexHEROTpl` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &randomize=`yes` &sortby=`RAND()` &depth=`1`]]  
        


        [[!getResources? &parents=`[[*portfolioFeedGenre]]` &limit=`4` &tpl=`portfolioFeedItemEvenTpl` &tplOdd=`portfolioFeedItemOddTpl` &includeContent=`1` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &randomize=`yes` &sortby=`RAND()` &hideContainers=`1`  &depth=`1` ]]
        


        No other plugins or snippets are being called on this page, its just the x3 gR calls as mentioned above, details of the hosting below:

        PHP Version 5.2.9, see attached PDF for the PHPinfo details... trust this gives you enough info? Let me know if not!


        Thanks for any insight you can offer here!

        Cheers,

        dubbs
        • You are including all of the content and processing all TV’s for each one of these calls. In particular the first one has a limit of 1000 Resources. How many Resources is it pulling? What is the timing for each one using the Executioner? If you want to optimize these, don’t include or process the TV’s, or exclude the main content field. The RAND() sorting also slows down the queries. (NOTE: randomize=`yes` is not a valid or needed getResources property)

          Also, I hope you are planning on caching these calls in the final site; running multiple uncached getResources calls on every request is definitely not going to be optimal.
            • 8168
            • 1,118 Posts
            Thanks for the tips Jason, I will investigate tomorrow (in UK here so its bedtime now!). Thanks for your insight - will report back!
              • 8168
              • 1,118 Posts
              Jason, caching the calls makes subsequent loads of a page much faster - I guess this is OK within the site, just means that the randomise of resources only occurs on initial load, once in the cache then its function is redundant it seems - until one clears the site cache in the manager anyway!
                • 8168
                • 1,118 Posts
                Jason, when you mention "don’t include or process the TV’s" What will this do to my snippet calls? Will this not ignore any TV data that is being fetched? Sorry if this is a dumb question! I am pretty new to gR and Revo ;]
                • Quote from: dubbs at Oct 15, 2010, 09:57 AM

                  Jason, caching the calls makes subsequent loads of a page much faster - I guess this is OK within the site, just means that the randomise of resources only occurs on initial load, once in the cache then its function is redundant it seems - until one clears the site cache in the manager anyway!
                  Another option is to call this with getPage and set the cache setting to a reasonable expiration interval. Even though you’ll never need the paging, you can provide an integer value in number of seconds for caching the results from getResources. You could also use a simple wrapper snippet that does the same caching logic without all the paging stuff; see this gist for a working example which I will publish soon.

                  Quote from: dubbs at Oct 15, 2010, 11:03 AM

                  Jason, when you mention "don’t include or process the TV’s" What will this do to my snippet calls? Will this not ignore any TV data that is being fetched? Sorry if this is a dumb question! I am pretty new to gR and Revo ;]
                  No, not including (or maybe just not processing, if you can use the raw values) the TV’s unless necessary is all I meant. They would not be available in your tpl in this case.