简体   繁体   中英

can't see describe queries in zend framework db profiler

I have zend database profiler set up and turned on in my development site. I can see all the queries except for the DESCRIBE queries, which I know it should be running each time I ask for a new table object. I'm using something like this to look at the queries:

$db = Zend_Registry::get('db');
$profiler = new Zend_Db_Profiler();
$profiler->setEnabled(true);
$db->setProfiler($profiler);

$i = 1;
$output = 'PROFILE FOR: '.$_SERVER['REQUEST_URI'] . "\n";

    foreach ($profiler->getQueryProfiles() as $query) {
        $output .= "Query ".$i++.": ".$query->getQuery(). "\n";
    }
    $output .= 'Average query length: ' . $totalTime / $queryCount .
                ' seconds' . "\n";

    $output .= 'Queries per second: ' . $queryCount / $totalTime . "\n";
    $output .= 'Longest query length: ' . $longestTime . "\n";
    $output .= "Longest query: \n" . $longestQuery . "\n\n";

    file_put_contents('/tmp/zend_profiler.log', $output, FILE_APPEND);
}

Not sure why I can't see the describe queries. Has anyone else run into this issue?

Maybe you have activated the metadata cache for you database connection (which usually is a very good thing especially in production). In that case the DESCRIBE queries won't be executed until the cache expires.

Verify it by executing this line somewhere in application after the bootstrap

if (null != Zend_Db_Table_Abstract::getDefaultMetadataCache()) {
  echo "Cache is active, describe queries not run";
} else {
  echo "Cache is not active";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM