Details
-
Bug
-
Resolution: Incomplete
-
Major - P3
-
None
-
None
-
None
-
ALL
Description
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/
|
|
|
);
|
Attachments
Issue Links
- related to
-
SERVER-7568 Aggregation framework favors non-blocking sorts
-
- Closed
-