The 32 gb memory
CPU: 8 nuclear
Hard disk raid5
DellR720
System: centos5.12 x64
Mongo version: 3.0.7 (2.6 tried the same)
Above is the server configuration and system, the most recent mongo database, the data quantity is only 500-600 - w, common query speed is normal, but the use of aggregate group aggregation query, speed is often in the 5 s +, the index also added a, want to ask next can from which aspects of screening screening?
Statement:
The getCollection (' Statistics'.) aggregate ([
{
"$match" : {
"Dateline" : {
"$gte" : 1443628800,
"$lte" : 1445270400
},
"Dar" : {
"$gt: 0
}
}
},
{
"$group" : {
"_id" : "$tid,"
"Event1" : {
"$sum" : 1
}
}
},
{
"$sort" : {
"Dar" : 1
}
},
{
"$skip" : 0
},
{
"$limit" : 10
}
])
Index:
& gt; Db. Statistics. GetIndexes ()
{
"V" : 1,
"Key" : {
"_id" : 1
},
"Name" : "_id_,"
"Ns" : "dbname. Statistics
"},
{
"V" : 1,
"Key" : {
1
"dateline" :},
"Name" : "dateline_1,"
"Ns" : "dbname. Statistics
"},
{
"V" : 1,
"Key" : {
1
"dar" :},
"Name" : "tid_1,"
"Ns" : "dbname. Statistics
"},
{
"V" : 1,
"Key" : {
"Dar" : 1,
1
"dateline" :},
"Name" : "tid_1_dateline_1,"
"Ns" : "dbname. Statistics
"}
]
CodePudding user response:
No one??CodePudding user response:
Add a db. Statistics. CreateIndex (} {dar: 1, the zipcode: - 1)Delete the last index
CodePudding user response:
What is the zipcode? Not quite understand?CodePudding user response:
Solved???????CodePudding user response:
About mongo aggregation query efficiency, you can refer to the official directing a BBShttp://forum.foxera.com/mongodb/topic/746/%E8%AF%B7%E6%95%99%E4%B8%8Bmongodb%E8%81%9A%E5%90%88%E6%9F%A5%E8%AF%A2mapreduce%E5%92%8Caggregate%E7%9A%84%E5%8C%BA%E5%88%AB-%E6%80%A7%E8%83%BD%E4%B8%8A%E6%AF%94%E8%BE%83%E4%BD%BF%E7%94%A8%E5%93%AA%E4%B8%AA%E6%9B%B4%E5%A5%BD? UN=109
CodePudding user response:
Index usage has a problem,{
"V" : 1,
"Key" : {
"Dateline" : 1,
1
"dar" :}
}
This, but the most time-consuming operation or in a group