We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27672
    • 168 Posts
    i’ve got exactly 81 web users so far, which is a pretty small amount, and will have a lot more.

    however at the bottom of my page i’m outputting the modx stats using the [^q^] method and noticed modx was doing 4721 queries on this page (by removing or using a cached webloginpe call it drops down to 7 queries).

    it appears for every single web user in the database it executes:
    $query = "SELECT * FROM ".$web_users.", ".$web_user_attributes.", ".$this->CustomTable." WHERE BINARY LOWER(".$web_users.".username) = '".strtolower($Username)."' AND ".$web_user_attributes.".`internalKey` = ".$web_users.".`id` AND ".$this->CustomTable.".`internalKey` = ".$web_users.".`id`";
    $query2 = "SELECT * FROM ".$web_users.", ".$web_user_attributes.", ".$this->CustomTable." WHERE(".$web_users.".username) = '".$Username."' AND ".$web_user_attributes.".`internalKey` = ".$web_users.".`id` AND ".$this->CustomTable.".`internalKey` = ".$web_users.".`id`";
    


    my page was also taking about 2.5 seconds to generate using the [^t^] value.

    i have been doing my call using the non-cached version [!WebLoginPE? &type=`users` &usersList=`...`!], i realize that by doing the cached call [[WebLoginPE? &type=`users` &usersList=`...`]] it won’t execute these queries everytime, but then it so also not loading the most current version of each user’s information - since WLPE doesn’t clear the cache when info is updated.

    any advice on how to reduce the number of queries? the amount of data queried isn’t huge, it seems to be the sheer number of calls that is slowing things down. thanks.
      • 31471
      • 206 Posts
      Look at this thread and try if it helps:
      http://modxcms.com/forums/index.php/topic,46089.0.html