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

    MODx 2.2.0

    I am using getCollectionGraph to pull data.
    There is a primary table with about 7 join tables, the total result set is about 4000 rows.

    The piece of code to fetch this data takes 24 seconds to run on my localhost!!

    I have looked at the query generated by xPDO, and have run it outside MODx, and it returns data in a couple of miliseconds.

    So my question is this....why so long?!?
      • 11055 ☆ A M B ☆
      • 3,112 Posts
      it would be helpful if you provide the query smiley
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • 15083
        • 697 Posts
        Yes that might make sense smiley
        I think I figured it out from another post.

        getCollectionGraph seems to create objects for all the data returned from the joins, so what you end up with is a nice php object with all your data. If I change the call to getCollection, its works fine, query returns in less than a second. If I use graph, 20+ seconds to pull query!!
        Ram usage for php goes right up, as its literally creating 4000+ objects.

        The solution is more DB queries as I have to use getMany, but the resulting code is far quicker.
        I guess getCollectionGraph is useful if you can segment the data and have a smaller result set. [ed. note: jusmeig last edited this post 14 years, 3 months ago.]