-
Type:
Bug
-
Resolution: Incomplete
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I Have 8 million records i created compound index on id,ind_id and is_valid this order.
I execute below query, I got 0.2 seconds match result but why $sortByCount result comes too slow.
It takes 2 minutes.
db.panelist.aggregate(
// Pipeline
[
// Stage 1
{
$match: {"$and":
[{id:{$in:[1,2,5,4]}},
{"ind_id":{$exists:true}}
]
}
},
// Stage 2
{
$project: {
"_id":0,
"id":1,
"ind_id":1,
"is_valid":1
}
},
// Stage 3
{
$sortByCount: "$is_valid"
},
],
// Options
{
cursor: {
batchSize: 50
},
allowDiskUse: true
}
// Created with Studio 3T, the IDE for MongoDB - https://studio3t.com/
);
- related to
-
SERVER-7568 Aggregation framework favors non-blocking sorts
-
- Closed
-