We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1887
    • 50 Posts
    The site I am building will have around 100 installers each of which can be on one of three levels. The number of installers is likely to double in the next couple of months.

    The list of installers need to be sorted primarily in the order of their installer level and then alphabetically but the site also allows for the installers to be filtered by region. For each installer level, the HTML output needs to be slightly different (change in colours and in some cases the information displayed).

    Which is better from a performance basis?

    Option 1:

    Run a single getResources which needs a &tvFilters for the region, a &sortbyTV for the level and a &sortby the pagetitle and then use modifiers to in a single chunk to output the HTML for each installer level.

    Option 2:

    Run getResources three times (once per installer level) in the right order but will need a &tvFilters for the region but each would have their own HTML chunk which would eliminate the modifiers (but does not need to be sorted by installer level).

    Right now all the installers are children to a single parent. With option 2, I could give them each there own parent which would reduce the amount of processing for the getResources but would complicate the admin a little bit.

    So in essence, is it better to run one more complex SQL query and then modify the output or run 3 simpler SQL queries and have less modifiers?

    I am using the latest Revo and the site is hosted on modxcloud.

    Kind regards

    James



    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      Try pdoTools and their pdoResources. It's much more efficient.

      In any case, as soon as you get TVs involved, things get a lot slower.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • discuss.answer
        • 4172
        • 5,888 Posts
        filtering and sorting by TVs is much slower, than filtering by resource-fields or proper indexed custom-table-fields.
        And using much output-filters to switch between different output-formats will make it even slower.

        You should try to use proper indexed custom-tables for filter/sort - fields, which are joined to your resource, if you can't use other existing resource-fields.
        Bob's class-extender might be usefull or just a plugin, which stores the TV-values into a custom-table.

        Also pdoResources of pdoTools should be faster than using getResources.

        If possible, try to use conditional-tpls, instaed of output-filters.
        In any case, you shouldn't have something like

        [[+level:is=`1`:then=`this information`]]
        [[+level:is=`2`:then=`another information`]]


        in your chunks

        better might be to use the &prepareSnippet - property of pdoTools to do the logical stuff.

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

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
        • discuss.answer
          • 3749
          • 24,544 Posts
          Option 3 wink

          Put the region, level, and any other custom fields in a separate table of an extended modResource object (or modUser -- I don't know if an "installer" is a person or not).

          Then you can get everything selected and sorted with a single query using getCollectionGraph() with no post processing necessary.

          As Bruno17 says, searching and sorting by TVs is very slow. Using conditional output modifiers is very slow. It's best to avoid both if possible.

            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
          • Hm... it's beginning to sound like having it so easy to extend a modResource (or any other class relating to resources) will make TVs and a lot of plugins obsolete. It comes a lot closer to having categories of resources instead of tying custom features to a resource's template.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 3749
              • 24,544 Posts
              I'd like to think so, but you still need to be able to create a schema or DB table, and you need to be able to modify a bit of modExt-flavored HTML to add the extra fields to the Create/Edit Resource table. You also need to be able to create a JSON 'where' property for searching and it won't work with Articles.

              I won't really know how hard it is to use ClassExtender until some more people try to adopt it. It seems easy enough for me, but I'm pretty familiar with it. wink

              Another consideration is that at present NewsPublisher won't handle the extra fields. I think I have the solution to that in my head, but it probably won't be implemented until I see significant demand for it.
                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
              • I can see that coming. modGalleryResource, modMediaSourceStaticResource, as well as a hundred variations on modBlogResource or modNewsResource. I never did like Articles.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 4172
                  • 5,888 Posts
                  I didn't play with ClassExtender, yet.
                  But I think it should be possible to combine MIGXdb and ClassExtender.
                  So you could use TV-input-types and configure Tabs and Fields with MIGXdb.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                  • I think I can see where blending the two would be useful. Instead of nested MIGx or MIGXdb TVs, you could have a custom Resource Type with a single MIGx TV. This would be much faster, not to mention easier to keep track of what is where.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 3749
                      • 24,544 Posts
                      I'm curious to see how the two might work together. It ought to give faster searching and sorting.
                        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