i have the following collection:
{ "_id" : ObjectId("61b75cd077a764166f282d24"), "name" : "topolino" }
{ "_id" : ObjectId("61b75cdd77a764166f282d25"), "name" : "tòpolino" }
and the following indexes (notice that i set up a default collation at the collection level)
db.collation.getIndexes()
[
{
"v" : 2,
"key" : {
"_id" : 1
},
"name" : "_id_",
"collation" : {
"locale" : "it",
"caseLevel" : false,
"caseFirst" : "off",
"strength" : 1,
"numericOrdering" : false,
"alternate" : "non-ignorable",
"maxVariable" : "punct",
"normalization" : false,
"backwards" : false,
"version" : "57.1"
}
},
{
"v" : 2,
"key" : {
"name" : 1
},
"name" : "name_1",
"collation" : {
"locale" : "it",
"caseLevel" : false,
"caseFirst" : "off",
"strength" : 1,
"numericOrdering" : false,
"alternate" : "non-ignorable",
"maxVariable" : "punct",
"normalization" : false,
"backwards" : false,
"version" : "57.1"
}
}
]
then i run "explain" on the following query:
db.collation.find({name: "topolino"},{_id : 0, name:1}).sort({name:1}).explain("executionStats");
i expected the query to be covered, since it searches only the "name" field and i explicitly removed the "_id" field. But the explain method shows:
"totalKeysExamined" : 2,
"totalDocsExamined" : 2,
which means that it still needs a FETCH step after the IXSCAN
Anybody can explain this behaviour? Thanks