Details
-
Improvement
-
Resolution: Done
-
Minor - P4
-
None
-
3.6.3
-
None
Description
Please note this isn't https://jira.mongodb.org/browse/SERVER-31760
Performing a `count` on a largish collection doesn't complete in what would be considered a reasonable time. Running this query won't complete (> 10 mins before giving up).
Venues is 500k objects, Tasks is 15mil. Indexes are in place to support this query.
db.venues.aggregate(
|
[
|
{
|
$match: {
|
|
}
|
},
|
{
|
$lookup: {
|
"from" : "tasks", |
"as" : "foreign", |
let: { localField: "$_id"}, |
"pipeline":[ |
{
|
"$match":{ |
"$expr":{ |
"$eq":["$v","$$localField"] |
}
|
}
|
},
|
{"$limit":1}, |
{"$count":"count"} |
]
|
}
|
},
|
{
|
$match: {"foreign.count":1} |
},
|
{
|
$count: "count" |
},
|
],
|
|
|
// Options |
{
|
cursor: {
|
batchSize: 50
|
}
|
}
|
);
|