MySource Matrix performance analysis : Log dump all database SQL queries

Posted by Rianto Wahyudi

MySource Matrix

Wanted to know why your mysource matrix installation running slow ?One major issue with our installation is  matrix execute large  number of SQL queries. The individual query by itself is very lightweight and executed fairly quick, but there are hundreds to thousands of queries required just to bring up a page.

I've experienced up to 5,000 SQL queries (  2 Mega Bytes in size !) just to bring up  2 KB html page. In this case,  powerful , grunty and well tuned  database server  just won't help improving  page load time. ( Network latency between app server and database server is  0.6 ms at best, so theoretical minimum page load time is 3 seconds. On top of that, there are databases and applications processing overhead. If combination of the database and application overhead takes around 0.5 millisecond to process, the page load time will be around 5.5 seconds. 5.5 seconds to bring up 1 html page with no assets  is too long !)






If you curious  to see these how many queries your matrix produce, you can use log_dump tools to log these queries into system.log To do this ,edit the  following file :


Add following  line at the top of the line :

require_once ('/fudge/dev/dev.inc');

Add log_dump() function at the end of  preparePdoQuery function ( Around line 285 - just before "return $query" )

return $query;

Output will be written to'/data/private/logs/system.log


Squiz Matrix 4.4.1 ships with awesome "Performance Mode".  It can be accessed just by appending /_performance at the end of  the URL of your matrix site.

From : http://www.squizlabs.com/squiz-matrix/squiz-matrix-performance-mode

Performance Mode will analyse the performance of the currently viewed asset present its findings at the base of your browser

These performance results will report the total time taken to load the asset and how much of this time can be attributed to system processing; the remaining time due to individual asset loading.

The individual assets that have been loaded will be listed chronologically, displaying their name, asset ID and asset type, as shown in the image below.

mysource matrix squiz performance