nscanned
dan nscannedObjects
laporkan hasil untuk rencana kueri
yang menang .
nscannedAllPlans
dan nscannedObjectsAllPlans
laporkan hasil untuk semua rencana.
Misalnya:
t = db.jstests_explainb;
t.drop();
t.ensureIndex( { a:1, b:1 } );
t.ensureIndex( { b:1, a:1 } );
t.save( { a:0, b:1 } );
t.save( { a:1, b:0 } );
// Older mongodb (< 3.0? )
t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).explain( true );
{
"isMultiKey": false,
"n": 2,
"nscannedObjects": 2,
"nscanned": 2,
"nscannedObjectsAllPlans": 6,
"nscannedAllPlans": 6,
"scanAndOrder": false,
"indexOnly": false,
"nYields": 0,
"nChunkSkips": 0,
"millis": 2,
...
}
// MongoDB 4.4
t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).explain( true );
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "test.jstests_explainb",
...
"queryHash" : "CB67518C",
"planCacheKey" : "5E76CDD1",
"winningPlan" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"a" : 1,
"b" : 1
},
"indexName" : "a_1_b_1",
}
},
"rejectedPlans" : [
{
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"b" : 1,
"a" : 1
},
"indexName" : "b_1_a_1",
}
}
],
...
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 2,
"executionTimeMillis" : 0,
"totalKeysExamined" : 2, // <-- same as `nscanned`
"totalDocsExamined" : 2, // <--
"executionStages" : { ... }
"allPlansExecution" : [
{...},
{...}
]
}