额外“计数”查询

发布于 2025-01-07 07:41:12 字数 1785 浏览 0 评论 0原文

我注意到 Cakephp 的日志中有很多额外的计数查询。它们看起来确实没有必要,而且会减慢速度。 有人知道它们的用途和/或如何将其删除吗?

 [194] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 81857
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [195] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 81857
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [196] => Array
            (
                [query] => UPDATE `gpx_points` SET `id` = 81857, `file_id` = 6, `zoom13` = '1'  WHERE `gpx_points`.`id` = 81857
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [197] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 71020
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [198] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 71020
                [affected] => 1
                [numRows] => 1
                [took] => 0
            )

        [199] => Array
            (
                [query] => UPDATE `gpx_points` SET `id` = 71020, `file_id` = 5, `zoom13` = '1'  WHERE `gpx_points`.`id` = 71020
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

I've noticed a lot of extra count queries in my logs in Cakephp. They seem really unnecessary and slowing things down.
Does anybody know what they are for and/or how they can be removed?

 [194] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 81857
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [195] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 81857
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [196] => Array
            (
                [query] => UPDATE `gpx_points` SET `id` = 81857, `file_id` = 6, `zoom13` = '1'  WHERE `gpx_points`.`id` = 81857
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [197] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 71020
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

        [198] => Array
            (
                [query] => SELECT COUNT(*) AS `count` FROM `gpx_points` AS `Point`   WHERE `Point`.`id` = 71020
                [affected] => 1
                [numRows] => 1
                [took] => 0
            )

        [199] => Array
            (
                [query] => UPDATE `gpx_points` SET `id` = 71020, `file_id` = 5, `zoom13` = '1'  WHERE `gpx_points`.`id` = 71020
                [affected] => 1
                [numRows] => 1
                [took] => 1
            )

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

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

发布评论

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

评论(1

别念他 2025-01-14 07:41:12

您可以临时将调试挂钩放入 Cake 内部,以查看从何处调用查询。

  1. 打开文件 cake\libs\model\datasources\dbo_source.php
  2. 找到 logQuery() 函数
  3. 在顶部添加:

    if(strpos($sql,'count')){ pr( 调试器::trace() ); }
    

You can temporarily put a debug hook into the Cake internals to see where the query is being called from.

  1. Open file cake\libs\model\datasources\dbo_source.php
  2. Find the logQuery() function
  3. At the top add:

    if(strpos($sql,'count')){ pr( Debugger::trace() ); }
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文