额外的“计数”查询

时间:2012-02-17 12:52:38

标签: cakephp

我在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
            )

1 个答案:

答案 0 :(得分:0)

您可以暂时将调试挂钩放入Cake内部,以查看调用查询的位置。

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

    if(strpos($sql,'count')){ pr( Debugger::trace() ); }