We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26876
    • 12 Posts
    Although we are not aware of any improvements that are in the new Revolution code branch, we found the save routine that generates siteCache.idx.php to be very slow for sites with a HUGE number of pages (can take up to a few minutes when saving a document via the modx manager).

    The major bottleneck we found was the getParents(...) function on line 122 of manager/processors/cache_sync.class.processor.php, which recursively creates the friendly url for all documents, on every save. In our case, this lead to the execution of about 34.000 queries on each save.

    Included is a patch that optimizes this section of cache_sync.class.processor.php by retrieving the aliases with a single query. It only works to a predefined depth (we use a maximum depth of 8 ), so if you have a deep document structure you might want to adjust the code a bit. Our findings were that this patch reduced the time required to generate the siteCache file from 12 to 0.5 seconds in a test environment, and reduced the 34.000 queries to a single query.

    Feel free to do with this patch as you wish (it’s ugly, but it works smiley

    -- Edited out a smiley where it should have said 8.
      • 34017
      • 898 Posts
      is the default depth 8
        Chuck the Trukk
        ProWebscape.com :: Nashville-WebDesign.com
        - - - - - - - -
        What are TV's? Here's some info below.
        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
        • 22303 MODX Staff
        • 10,725 Posts
        Shadoze:

        That’s a very interesting solution indeed; in fact we could easily create a max_friendly_alias_path_depth setting I suppose and work this into the core for MODx Evolution 1.0. I think this is worth both a Feature Request in JIRA as well as a code review of the patch in Crucible. We can then at least vote on the feature and work out any details.

        As for Revolution, there is still some issue with this, and I will be looking at this solution to see how it can be applied to the context cache building routines. Ideally though, I’d like to find a solution to the depth limitation, but perhaps this is the best approach at the moment.

        Thanks for sharing your work.
          • 26876
          • 12 Posts
          Another possibility would be to combine the query building method with a recursive approach: Build the query with a pre-set max-depth and execute it. If the last alias is not NULL, do the same query starting at the last alias/id, etc.

          MODx could even up the (initial default) max-depth setting if it encounters deeper paths, or lower it. Since all documents are processed at that time, it’s easy enough to keep a record of the deepest found path. The max-depth setting would then just be an internal MODx setting.

          This should cover any problems with deeper paths while still using a minimum number of queries.
            • 7923
            • 4,213 Posts
            Is this added to Jira? would be a shame to loose this buried in to the forums smiley


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 24719
              • 194 Posts
              good call doze, i missed this the first time round. this is exactly what i’ve needed for a while.

              thanks shadoze (are you two related tongue)
                • 7923
                • 4,213 Posts
                Quote from: redman at Oct 17, 2008, 09:09 AM

                thanks shadoze (are you two related tongue)
                Not that I know of... wink


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 25663 MODX Staff
                  • 12,272 Posts
                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                    • 7923
                    • 4,213 Posts
                    Great!


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 36416
                      • 589 Posts
                      Quote from: rthrash at Oct 17, 2008, 10:36 AM

                      http://svn.modxcms.com/jira/browse/MODX-446

                      Was this integrated into 0.9.6.3 ?