php中MongoCursor遍历成数组很慢
$mongo = new MongoClient('mongodb://localhost:27017');
$filter['every_day'] = array('$gte' => "2017-01-01", '$lte' => "2017-09-30");
$cursor = $mongo->selectCollection('db', 'test')->find($filter);
$data = [];
$starttime = explode(' ', microtime());
foreach ($cursor as $id => $value) {
$data[] = $value;
}
$endtime = explode(' ', microtime());
$thistime = $endtime[0] + $endtime[1] - ($starttime[0] + $starttime[1]);
$thistime = round($thistime, 3);
echo "执行耗时:" . $thistime . " 秒。<br/>";
这段代码,从mongodb里面查询数据,数据大概6000条,但是当使用foreach转换成数组时候,大概需要4秒。
那位大神帮我看下,有什么问题?