We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11858
    • 130 Posts
    I’m using getresources to populate a table that has 300 resources in it. It is timing out with this message:

    Fatal error: Maximum execution time of 30 seconds exceeded

    I am hosted on bluehost, so yes it’s the cheapest of the cheap hosting. Could this be my problem? As soon as I limit the results, speed returns. It’s also grabbing values from ~13 TVs for each resource to populate the table. Am I just overworking bluehost? I have done this before in Evo with Ditto and there’s no problems... of course getResources is heavier but I didn’t think it would be this heavy!

    Any ideas for making this work?

    Thanks!
      • 3749
      • 24,544 Posts
      I’m not sure, but I think in addition to retrieving the 300 resources, getResources will be retrieving the 13 TV objects 300 times each (unnecessarily), though it should be retrieving them from the cache rather than the DB. You would be better off with a custom snippet that retrieves each TV once, then gets its value for each resource. You could also probably query the mox_site_templatevar_contentvalues table directly and skip getting the TV objects.

      Better yet, probably, would be putting the data that’s in the TVs in a custom table (along with any resource field data that’s needed) and creating a snippet that periodically updates that table. Then you could just quickly pull the data for your on-screen table from that table without getting any MODX objects and without all the overhead of grabbing unused fields of the TVs and Resources.

      There are probably ways of optimizing the getResources call, but others are better qualified to comment on that than I am.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 4172
        • 5,888 Posts
        Quote from: Hat-rack at Jun 25, 2011, 03:39 AM

        I’m using getresources to populate a table that has 300 resources in it. It is timing out with this message:

        Fatal error: Maximum execution time of 30 seconds exceeded

        I am hosted on bluehost, so yes it’s the cheapest of the cheap hosting. Could this be my problem? As soon as I limit the results, speed returns. It’s also grabbing values from ~13 TVs for each resource to populate the table. Am I just overworking bluehost? I have done this before in Evo with Ditto and there’s no problems... of course getResources is heavier but I didn’t think it would be this heavy!

        Any ideas for making this work?

        Thanks!

        Do you want to show us your getResources-tpl and your call for getResources?
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 11858
          • 130 Posts
          The website this is on is http://www.centurionrunning.com, an ultramarathon series.

          My getResources call (3 calls, 100 records each as there is max 100 entrants in each race distance)

          
          <h2>NDW100</h2>
          [[$runnerStatsTableHeadLive]]
          [[getResources? &parents=`309` &tpl=`runnerStatsTplLive` &limit=`50`]]
          </table>
          
          <h2>NDW50</h2>
          [[$runnerStatsTableHeadLive]]
          [[getResources? &parents=`310` &tpl=`runnerStatsTplLive` &limit=`50`]]
          </table>
          
          <h2>NDW26.2</h2>
          [[$runnerStatsTableHeadLive]]
          [[getResources? &parents=`311` &tpl=`runnerStatsTplLive` &limit=`50`]]
          </table>
          
          


          With the limit of 50 in there it takes 10 seconds to load. Still not good. You can see at http://www.centurionrunning.com/live

          The tpl:

          
          <tr>
          <td> 
          <a href="[[~[[+id]]]]">[[+pagetitle]]</a>
          </td>
          
          <td>
          [[+tv.competitorNumber]]
          </td>
          
          <td>
          [[+tv.country]]
          </td>
          
          
          <td>
          [[+tv.NDWMarker01_0]]
          </td>
          
          <td>
          [[+tv.NDWMarker02_3.5]]
          </td>
          
          <td>
          [[+tv.NDWMarker03_6.6]]
          </td>
          
          <td>
          [[+tv.NDWMarker04_13.1]]
          </td>
          
          <td>
          [[+tv.NDWMarker05_23.9]]
          </td>
          
          <td>
          [[+tv.NDWMarker06_31.8]]
          </td>
          
          <td>
          [[+tv.NDWMarker07_43]]
          </td>
          
          <td>
          [[+tv.NDWMarker08_50.3]]
          </td>
          
          <td>
          [[+tv.NDWMarker09_57]]
          </td>
          
          <td>
          [[+tv.NDWMarker10_68.2]]
          </td>
          
          <td>
          [[+tv.NDWMarker11_76.1]]
          </td>
          
          <td>
          [[+tv.NDWMarker12_86.9]]
          </td>
          
          <td>
          [[+tv.NDWMarker13_93.4]]
          </td>
          
          <td>
          [[+tv.NDWMarker14_97.1]]
          </td>
          
          <td>
          [[+tv.NDWMarker15_100.6]]
          </td>
          </tr>
          
          


          So yes, lots of TVs.

          The reason I didn’t use custom tables (one table for runners names, on table for events, one table with an id to each runner and then their times) is I have someone who is not technically inclined entering the values and using resources and tvs, so while not the most efficient way, is the easiest in terms of user interface.

          Could I use something like http://modxcms.com/forums/index.php?topic=56636.0 to make custom table editing easy for content editors?

          I will have to go to custom tables in the future but thought this could get me over the line for this race, maybe not!
            • 4172
            • 5,888 Posts
            I’m sure, the most time needs parsing and replacing all the placeholders the first time.
            After caching this should run a lot faster, doesn’t it?

            To speed up the first run you could try that:

            You can render the output of a row (resource) for example to the content-field of that resource with a plugin ’onDocFormSave’, each time one creates or updates a resource.
            This is a kind of precaching each row as a rendered value into one field.
            Then put in your getResources-tpl only this field-placeholder:
            [[+content]]


            This costs much less parsing-time the first time (I think about 10 times and more faster), because getResources has only one placeholder to replace and doesn’t need to get any TVs.

            And yes you could manage that of course also with a custom-table and a CMP created with help of xdbedit.
            But I think the problem is more the parsing-time of that lots of placeholders, which you could speed up by the method above.
            In any case, to store this sort of data to custom-tables is allways a good idea.

              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 12236
              • 48 Posts
              Digital Butter - MODX Premiere Partners Reply #6, 15 years, 3 months ago
              Quote from: Bruno17 at Jun 26, 2011, 02:03 PM

              I’m sure, the most time needs parsing and replacing all the placeholders the first time.
              After caching this should run a lot faster, doesn’t it?

              To speed up the first run you could try that:

              You can render the output of a row (resource) for example to the content-field of that resource with a plugin ’onDocFormSave’, each time one creates or updates a resource.
              This is a kind of precaching each row as a rendered value into one field.
              Then put in your getResources-tpl only this field-placeholder:
              [[+content]]


              This costs much less parsing-time the first time (I think about 10 times and more faster), because getResources has only one placeholder to replace and doesn’t need to get any TVs.

              And yes you could manage that of course also with a custom-table and a CMP created with help of xdbedit.
              But I think the problem is more the parsing-time of that lots of placeholders, which you could speed up by the method above.
              In any case, to store this sort of data to custom-tables is allways a good idea.



              Never thought of pre-caching like that, neat little idea...
                • 11858
                • 130 Posts
                I’ve decided to go the custom table route as that’s the Right Thing To Do, and it is faster but I’ve hit the same kind of slow performance problem with a more detailed query/loop. I am blaming 50% of the slowdown at bluehost and the other 50% at my noob experience of xpdo, so if anyone wants to see this continued read here: http://modxcms.com/forums/index.php/topic,66732.0.html
                  • 3749
                  • 24,544 Posts
                  The site in my sig is at Bluehost and I think the speed is fairly good (YMMV). No getResources calls at all, but a fairly bulky Wayfinder menu.

                  The Manager is painfully slow, but I haven’t had time to update for a while.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 11858
                    • 130 Posts
                    I have a few other sites which are really light and they run fine on bluehost. Yes the backend is a little slow (running 2.0.8 at the moment) but it’s *just* ok for day to day use. Any slower and I’d have to move.

                    I think that’s bluehosts achilles heel - anything with a fair bit of processing, like a big getResources call or the modx backend, it doesn’t have enough grunt as it seems to be oversubscribed. Was on a recent tech support chat and they mentioned upgrading to a $20/month plan puts you on a 24 core server shared with max 200 people. They said the normal plan was shared with 700+ people, same 24 core machine. But hey, I’m paying ~$4/ month!

                    So I could expect 60-75% reduction in load times by paying $20 month. I wonder if there is a tool out there that can compare different hosts speed?

                    EDIT: I’ve just found this site, http://www.domaintools.com/research/reverse-ip/ and it looks as if my site is sharing the same server with 2,661 other sites!! so the + bit of 700+ was definitely important...
                      • 3749
                      • 24,544 Posts
                      Lucky me. I’ve only got 647 "neighbors."

                      I imagine that some of them are parked or inactive domains (several of mine are).
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting