MongoDB Tutorial 0/120 lessons ~6 min read Lesson 68

    Explain Plans

    explain() is your X-ray.

    Course progress0%
    Focus
    3 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    explain() is your X-ray. It shows which index was used, how many documents were scanned vs returned, and whether a sort was in-memory or indexed. Reading explain output is a senior-engineer skill.

    Syntax reference

    js
    db.orders.find({ userId: 1 }).explain("executionStats");

    Best practices

    • Look for IXSCAN (good) vs COLLSCAN (bad).
    • Compare nReturned to totalDocsExamined — close to 1:1 is ideal.
    Ready to mark this lesson complete?Track your journey across the entire course.