我正在研究如何比较CRUD操作中的MySQL和MongoDB性能。 当我执行此查询时:
$arrayFind = array(
'$and' => array (
array('ct_adult' => array('$lte' => (int) $_GET['adult'] )),
array('max_adult' => array('$gte' => (int) $_GET['adult'] )),
array('ct_child' => array('$gte' => (int) $_GET['children'] )),
array('min_people' => array('$lte' => (int) $people)),
array('max_people' => array('$gte' => (int) $people)),
array('dt_length' => array('$gte' => (int) $_GET['length'])),
array('code_food' => (string) $_GET['food'])
)
);
$m = new MongoClient("mongodb://10.0.1.11:27010");
$db = $m->mydb;
$offers = new MongoCollection($db, 'offers');;
$cursor = $offers->find($arrayFind)->limit(10);
foreach ($cursor as $document) {
...
}
当没有结果时(脚本等待30秒),我收到超时错误。
Uncaught exception 'MongoCursorTimeoutException' with message '10.0.1.11:27010: cursor timed out
当有结果时,我会在1秒内及时得到它们。我试图使用'count()'方法解决这个问题,但它没有用。这个超时有什么解决方案吗?你如何处理mongo中的搜索结果?