We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11975
    • 2,542 Posts
    This is an auto-generated support/comment thread for SSR.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Execute snippet from ditto chunk and store the value in modx placeholders
    Reduce the amount of db queries for similar snippet call

    here are some test results
    With 198 documents
    Ditto call

    [!ditto? &parents=`0` &tpl=`photolist` &summarize=`198` &depth=`4` &paginate=`1` &limit=`200` &filter=`isfolder,1,2` !]

    with
    [[GetField? &docid=`[+parent+]` &field=`pagetitle` ]]

    MySQL: 1.6104 s, 413 request(s)

    with
    [[SSR? &ph_ID=`[+parent+]` &phName=`ditto_parent_name` &snippetName=`GetField` &snippetParams=`docid:[+parent+]|field:pagetitle` ]]
    MySQL: 1.6374 s, 216 request(s)
      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
      • 25663 MODX Staff
      • 12,272 Posts
      Thanks heliotrope... always very glad to see yet another way to get to the same end result in MODx laugh. Why is the fewer requests taking longer to execute though? Wonder what it would look like with 1000s of documents...

      I’m not quite sure I follow what this does exactly though ... :/ Sorry for being dense!
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 11975
        • 2,542 Posts
        Hi Ryan,

        The aim of SSR is to reduce the amount of query to get the same information

        For instance you wish to display in your ditto chunk the parent name for each doc.
        To do so, you will call from the ditto chunk the getField Snippet.

        When documents shares the same information that’s a pity to run a db query for each doc when you can store the value for other documents.

        About the sql execution time, I’m testing locally on my powerbook.
        The speed is very variable. My latest try returns MySQL: 1.0181 s,

        :-)
          Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
          • 11975
          • 2,542 Posts
          Here are some new results

          For 785 docs

          MySQL: 1.0856 s, 686 request(s), SSR
          MySQL: 1.8266 s, 1332 request(s), GetField

          :-)
            Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
            • 25663 MODX Staff
            • 12,272 Posts
            I call shenanigans. Maybe tomfoolery ... most likely both actually. tongue

            It didn’t make sense that 2x the queries was actually quicker. Reducing queries does make sense. smiley
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 11975
              • 2,542 Posts
              It seems that my ditto version was buggy

              here are the right figures

              Ditto Summarize set to 100

              GetField called from SSR in ditto chunk to display parent name
              MySQL: 0.2084 s, 24 request(s)

              GetField in ditto Chunk
              MySQL: 0.2943 s, 113 request(s)

              Ditto Summarize set to 500

              GetField called from SSR
              MySQL: 0.6187 s, 31 request(s)

              GetField
              MySQL: 1.0613 s, 512 request(s),


              :-)
                Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                • 6726
                • 7,075 Posts
                Another great contrib’, certainly useful when you have high document counts smiley (It’ll justify learning a new snippet !)
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l'outil id
                  • 18830
                  • 161 Posts
                  I just stumbled upon this Snippet and it seems to be a very interesting one. But I don´t understand how to use. Could I use it in a case like this?

                  [[GetField?  &field=`pagetitle` &docid=`[*phx:get=`id`*]` ]]
                  …
                  [[GetField? &field=`bn_stadt` &docid=`[[GetField? &docid=`[*phx:get=`id`*]` &field=`st_buehne`  ]]` ]]
                  …
                  [[GetField? &docid=`[*phx:get=`id`*]` &field=`st_buehne`  ]]` ]]
                  …
                  


                  and so on. There are about a dozen more of this queries to get fields from the same id and this doesn´t seem to be very efficient. How could I speed up the thing with SSR?