I deduce numbers in ModX Revo (inserted in the bottom of the template):
MySQL: [^qt^], [^q^] request(s), PHP: [^p^], total: [^t^], document from [^s^] Snippet code - 1 variant (output 32 lines of 5 cells from the database):
$query = $modx->query($sql); while ($i= $query->fetch(PDO::FETCH_ASSOC)) {блабла} Watching the numbers:
MySQL: 0.4114 s, 32 request (s), PHP: 0.1472 s, total: 0.5586 s, document from database
MySQL: 0.3293 s, 3 request (s), PHP: 0.0904 s, total: 0.4197 s, document from cache
Snippet code - option 2 :
$query = $modx->prepare($sql); $query->execute(); while ($i= $query->fetch(PDO::FETCH_ASSOC)) {блабла} Watching the numbers:
MySQL: 0.0098 s, 31 request (s), PHP: 0.5625 s, total: 0.5722 s, document from database
MySQL: 0.0005 s, 2 request (s), PHP: 0.4296 s, total: 0.4301 s, document from cache
How so? The total time of the formation of the page is essentially the same, but variations in the components .. What is the way to choose?
UPD.
Version of ModX Revo.
Output from custom table.
Query: SELECT text, link FROM custom_table WHERE order_id>0
What for? The site has a high attendance, this request should be implemented for each visitor, the cache is not possible, since the data in the table is updated every 5-10 minutes. Do cash for 10 minutes? Perhaps))) That is, with a large load, something will be more subtle or PHP or MySQL.