Mongodb 10M集合上的聚合框架性能
我收集了1000万份文档,这是对日常事件的预先汇总 一个简单的Mongodb 10M集合上的聚合框架性能,mongodb,Mongodb,我收集了1000万份文档,这是对日常事件的预先汇总 一个简单的$group花费了8秒以上,这种性能正常吗 探查器中的某些日期: { "op" : "command", "ns" : "analytics.$cmd", "command" : { "aggregate" : "aggregation", "pipeline" : [ { "$group" : {
$group
花费了8秒以上,这种性能正常吗
探查器中的某些日期:
{
"op" : "command",
"ns" : "analytics.$cmd",
"command" : {
"aggregate" : "aggregation",
"pipeline" : [
{
"$group" : {
"_id" : "",
"hits" : {
"$sum" : "$hits"
}
}
}
]
},
"ntoreturn" : 1,
"keyUpdates" : 0,
"numYield" : 15,
"lockStats" : {
"timeLockedMicros" : {
"r" : NumberLong(17169805),
"w" : NumberLong(0)
},
"timeAcquiringMicros" : {
"r" : NumberLong(8582619),
"w" : NumberLong(294)
}
},
"responseLength" : 78,
"millis" : 8594,
"ts" : ISODate("2013-12-04T15:57:38.217Z"),
"client" : "127.0.0.1",
"allUsers" : [ ],
"user" : ""
}
这里只有一份文件
{
"_id" : ObjectId("529e21ee67e807418500daeb"),
"date" : ISODate("2012-09-19T00:00:00Z"),
"hits" : 1,
"infos" : {
"sourceValue" : NumberLong(1),
"eventType" : "createUser",
"sourceType" : "user",
"instance" : "xxx",
"targetType" : "user",
"targetValue" : NumberLong(15)
}
}
LOL:1000万份文档上的“一个简单的组”。尝试在SQL数据库上执行此操作。8秒很快……我必须同意,你是在对所有10万条记录进行汇总,然后说你的性能很差,与什么相比,性能很差?我的笔记本电脑(200毫秒)上的10万个整数进行汇总@sammayes汇总在哪里?在一个普通的程序中,我可以理解,您在这里使用了整个数据库,我比较了在一个小测试程序中对10M个整数进行求和,以及在MongoDB中对给定字段上对10M个文档(整个集合)进行求和。在这两种情况下,数据都在内存中,因此执行时间应该相似。我错了吗?