2012-07-16 87 views
1

我正在使用explain来简单查询以准确知道执行时间。如何使用MongoDB和PHP中的Map Reduce查询的说明

$this->db->toto->find($req)->sort(array('date' => 1))->explain(); 

我现在想在地图上使用解释并减少查询,怎么做? 我应该使用'经典'分析系统吗?

我想比较这两个查询的执行时间。

例如:

$res = $this->db->command(array(
     "mapreduce" => "toto", 
     "map" => $map, 
     "reduce" => $reduce, 
     "finalize" => $finalize, 
     "query" => $req, 
     "out" => array("inline"=>1) 
    ))->explain(); 

不起作用,因为命令返回数组(请说明需要MongoCursor)。

非常感谢你:)

回答

2

解释不会对像map/reduce这样的命令起作用。你可以做的节奏是运行你正在使用的查询的解释。

如果您只需要执行时间,您可以运行m/r并计时。这就是解释如何确定执行时间。