Hi @Prasad_Saya, thank for that explanation.
Here is the explain output:
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "catalog.akka_persistence_journal_CategoryTree",
"indexFilterSet" : false,
"parsedQuery" : {
"$and" : [
{
"pid" : {
"$eq" : "CategoryTree-46"
}
},
{
"to" : {
"$lte" : 27.0
}
},
{
"from" : {
"$gte" : 21.0
}
}
]
},
"winningPlan" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"pid" : 1,
"to" : -1,
"from" : -1
},
"indexName" : "pid_1_to_-1_from_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"pid" : [],
"to" : [],
"from" : []
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"pid" : [
"[\"CategoryTree-46\", \"CategoryTree-46\"]"
],
"to" : [
"[-inf.0, 27.0]"
],
"from" : [
"[21.0, inf.0]"
]
}
}
},
"rejectedPlans" : [
{
"stage" : "FETCH",
"filter" : {
"from" : {
"$gte" : 21.0
}
},
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"pid" : 1,
"to" : -1
},
"indexName" : "pid_seq",
"isMultiKey" : false,
"multiKeyPaths" : {
"pid" : [],
"to" : []
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"pid" : [
"[\"CategoryTree-46\", \"CategoryTree-46\"]"
],
"to" : [
"[-inf.0, 27.0]"
]
}
}
}
]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 7,
"executionTimeMillis" : 1,
"totalKeysExamined" : 28,
"totalDocsExamined" : 7,
"executionStages" : {
"stage" : "FETCH",
"nReturned" : 7,
"executionTimeMillisEstimate" : 0,
"works" : 29,
"advanced" : 7,
"needTime" : 20,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"docsExamined" : 7,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "IXSCAN",
"nReturned" : 7,
"executionTimeMillisEstimate" : 0,
"works" : 28,
"advanced" : 7,
"needTime" : 20,
"needYield" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"keyPattern" : {
"pid" : 1,
"to" : -1,
"from" : -1
},
"indexName" : "pid_1_to_-1_from_-1",
"isMultiKey" : false,
"multiKeyPaths" : {
"pid" : [],
"to" : [],
"from" : []
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "backward",
"indexBounds" : {
"pid" : [
"[\"CategoryTree-46\", \"CategoryTree-46\"]"
],
"to" : [
"[-inf.0, 27.0]"
],
"from" : [
"[21.0, inf.0]"
]
},
"keysExamined" : 28,
"seeks" : 21,
"dupsTested" : 0,
"dupsDropped" : 0
}
}
},
"serverInfo" : {
"host" : "e2a568b9a111",
"port" : 27017,
"version" : "4.4.4",
"gitVersion" : "8db30a63db1a9d84bdcad0c83369623f708e0397"
},
"ok" : 1.0
}