skip to content
Alvin Lucillo

Find execution information

/ 1 min read

If you need to know information about the queries like find, you can use explain with allPlansExecution verbosity mode. See example below:

Command: db.birds.find({common_name: 'Northern Cardinal'}).explain("allPlansExecution")

{
  explainVersion: '1',
  queryPlanner: {
    namespace: 'bird_data.birds',
    indexFilterSet: false,
    parsedQuery: { common_name: { '$eq': 'Northern Cardinal' } },
    queryHash: '42C61951',
    planCacheKey: '42C61951',
    maxIndexedOrSolutionsReached: false,
    maxIndexedAndSolutionsReached: false,
    maxScansToExplodeReached: false,
    winningPlan: {
      stage: 'COLLSCAN',
      filter: { common_name: { '$eq': 'Northern Cardinal' } },
      direction: 'forward'
    },
    rejectedPlans: []
  },
  executionStats: {
    executionSuccess: true,
    nReturned: 1,
    executionTimeMillis: 0,
    totalKeysExamined: 0,
    totalDocsExamined: 12,
    executionStages: {
      stage: 'COLLSCAN',
      filter: { common_name: { '$eq': 'Northern Cardinal' } },
      nReturned: 1,
      executionTimeMillisEstimate: 0,
      works: 13,
      advanced: 1,
      needTime: 11,
      needYield: 0,
      saveState: 0,
      restoreState: 0,
      isEOF: 1,
      direction: 'forward',
      docsExamined: 12
    },
    allPlansExecution: []
  },
  command: {
    find: 'birds',
    filter: { common_name: 'Northern Cardinal' },
    '$db': 'bird_data'
  },
  serverInfo: {
    host: 'atlas-d3opcw-shard-00-02.3xfvk.mongodb.net',
    port: 27017,
    version: '7.0.18',
    gitVersion: '1624e181d0dac03edb34ef25b9b58a6d79969825'
  },
  serverParameters: {
    internalQueryFacetBufferSizeBytes: 104857600,
    internalQueryFacetMaxOutputDocSizeBytes: 104857600,
    internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600,
    internalDocumentSourceGroupMaxMemoryBytes: 104857600,
    internalQueryMaxBlockingSortMemoryUsageBytes: 104857600,
    internalQueryProhibitBlockingMergeOnMongoS: 0,
    internalQueryMaxAddToSetBytes: 104857600,
    internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600,
    internalQueryFrameworkControl: 'forceClassicEngine'
  },
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1745497846, i: 1 }),
    signature: {
      hash: Binary.createFromBase64('rZT0KNyaBhPygsdWNNyjhq/H13s=', 0),
      keyId: Long('7458182581763178503')
    }
  },
  operationTime: Timestamp({ t: 1745497846, i: 1 })
}