$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秒。
那位大神幫我看下,有什么問題?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/106501.html
標籤:MongoDB
上一篇:三張表關聯,通過條件查詢
