php连接远程mongodb查询很慢,查询数据量大概6000条,大概用了4秒。
求大神请教下,怎么连接远程monogdb,是代码问题还是需要配置什么?
$mongo = new MongoClient('mongodb://xx.xx.xx.xx:27017/test');
$filter['every_day'] = array('$gte' => "2017-01-01", '$lte' => "2017-09-30");
$cursor = $mongo->selectCollection('test', '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 . " 秒。";