Answer the question
In order to leave comments, you need to log in
Mongodb aggregation - why is it so slow?
Good evening everyone!
There is a limited collection:
db.createCollection("Error", {capped:true, size:419430400, max:200000})
db.Error.aggregate (
[
{
"$match" : {
"dateAdd" : {
"$gt" : ISODate("2014-05-11T13:16:52Z"),
"$lte" : ISODate("2014-05-12T13:16:52Z")
}
}
},
{
"$group" : {
"_id" : {
"server" : "$server",
"errorType" : "$errorType"
},
"count" : {
"$sum" : NumberLong(1)
}
}
}
]
)
db.Error.ensureIndex({web:1, hash:1, dateAdd:1});
db.Error.ensureIndex({type:1, dateAdd:1})
db.Error.ensureIndex({web:1, type:1, dateAdd:1});
db.Error.ensureIndex({dateAdd:1})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question