这个代码大约需要0.1秒PHP蒙戈的光标速度很慢
// find
$benchmark = Profiler::start ('Testing', 'find()');
$cursor = MongoBG::getInstance ()->setDatabase ('test')->setCollection ('testcoll')->find();
Profiler::stop ($benchmark);
$benchmark = Profiler::start ('Testing', 'cursor walk');
while ($cursor->hasNext()) {
print_r($cursor->getNext());
}
Profiler::stop ($benchmark);
因此“找到()”只用了0.000017秒 但“光标游走”0.102812秒
收集大约是100行,速度与1000个或仅10个项目相同。
某些服务器信息: 的FreeBSD 8.1,PHP 5.3.5与(蒙戈/ 1.1.4),MongoDB的版本1.6.6预
@mika:我非常怀疑它需要0.0005s的Python连接到数据库并检索结果。上述测试不具代表性。 – johndodo 2011-12-19 12:00:54