这是我的环境.
Java-1.7 by Oracle
mongod v2.4.5(在Mongolab中)
我发现两个MongoDB驱动程序的性能有所不同(2.9.3与2.11.2)
当我使用每个驱动程序运行相同的代码时,2.11.2比2.9.3慢.
for(int i=0; i<1000; i++){
BasicDBObject doc = new BasicDBObject(
"currentTime",
new SimpleDateFormat("HH:mm:ss:SSS").format(Calendar.getInstance().getTime())
);
coll.insert(doc);
}
DBCursor cursor = coll.find();
try{
while(cursor.hasNext()){
System.out.println(cursor.next());
}
} finally {
cursor.close();
}
上面的代码是将1000个文档放入MongoDB.
在驱动程序2.9.3中,需要1到2秒.
但在2.11.2中,则需要1分钟以上的时间.
有人知道这个问题吗?