Home > database >  PHP MongoCursor traverse into an array of slowly
PHP MongoCursor traverse into an array of slowly

Time:10-02

$mongo=new MongoClient (' mongo://localhost: 27017 ');
$filter [' every_day]=array (' $gte=& gt; "2017-01-01", '$lte=& gt; "2017-09-30");
$cursor=$mongo - & gt; SelectCollection (' db ', 'test') - & gt; Find ($filter);
$data []=https://bbs.csdn.net/topics/;
$starttime=explodes (' ', microtime ());
The foreach ($cursor as $id=& gt; {$value)
$data []=$value;
}
$endtime=explodes (' ', microtime ());
$thistime=$endtime $endtime [0] + [1] - [$starttime [0] + $starttime [1]).
$thistime=round ($thistime, 3);
Echo "execution time:". $thistime. "second, & lt; Br/& gt; ";

This code from the mongo query data, the data about 6000, but when use foreach converted into an array, probably need 4 seconds,

The great god to help me see, what's the problem?
  • Related