Answer the question
In order to leave comments, you need to log in
How to understand the reason for fetch behavior in MongoDB?
Greetings. Input data:
- a collection of about 11.5 million records
- each document has a string format field, which can either have a string or an empty value
- each document has a numeric field from 0 to 100, which is used in sorts
Query 1 (1.74 sec) = 5971171:
db.getCollection('channels').find(
{ 'update': { $gt: '' }}
).count();
db.getCollection('channels').find(
{ 'update': { $eq: '' }}
).count();
db.getCollection('channels').find(
{ 'update': { $gt: '' }}
).sort(
{ 'sort': -1 }
).limit(1);
db.getCollection('channels').find(
{ 'update': { $eq: '' }}
).sort(
{ 'sort': -1 }
).limit(1);
_sort_ {
"sort" : -1
}
_update_ {
"update" : 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