Created
October 26, 2012 22:19
-
-
Save vdubyna/3961901 to your computer and use it in GitHub Desktop.
Profile db queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mage::run($mageRunCode, $mageRunType); | |
//Insert code after Mage run | |
/** @var $profiler Zend_Db_Profiler */ | |
$profiler = Mage::getSingleton('core/resource')->getConnection()->getProfiler(); | |
$log = date('Y-m-d_H:i:s') . uniqid(); | |
Mage::log('Total queries: ' . count($profiler->getQueryProfiles()), null, $log); | |
Mage::log('Total sec: ' . $profiler->getTotalElapsedSecs(), null, $log); | |
foreach ($profiler->getQueryProfiles() as $query) { | |
/** @var $query Zend_Db_Profiler_Query */ | |
Mage::log($query->getElapsedSecs() . "\n" .$query->getQuery() . "\n" . print_r($query->getQueryParams(), 1), null, $log); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<config> | |
<global> | |
<resources> | |
<default_setup> | |
<connection> | |
<profiler>true</profiler> | |
</connection> | |
</default_setup> | |
</resources> | |
</global> | |
</config> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment