在 zend 框架 db profiler 中看不到描述查询

发布于 2024-11-30 05:57:05 字数 870 浏览 1 评论 0原文

我在我的开发站点中设置并打开了 zend 数据库分析器。我可以看到除 DESCRIBE 查询之外的所有查询,我知道每次我请求新的表对象时它都应该运行。我正在使用类似的东西来查看查询:

$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);
}

不知道为什么我看不到描述查询。还有其他人遇到过这个问题吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弥繁 2024-12-07 05:57:05

也许您已经为数据库连接激活了元数据缓存(这通常是一件非常好的事情,尤其是在生产中)。在这种情况下,在缓存过期之前,DESCRIBE 查询不会被执行。

通过在引导程序后在应用程序中的某个位置执行此行来验证它

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

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";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文