| 语法 | db.collection.find(...).explain("executionStats") |
|---|---|
| 关键字段 | winningPlan.stage / totalKeysExamined / totalDocsExamined / nReturned |
| 判断标准 | docsExamined 接近 nReturned 说明过滤高效 |
示例
示例
db.orders.find({ status: "paid" }).explain("executionStats")
db.orders.aggregate([{ $match: { status: "paid" } }], { explain: true })聚合管道用 { explain: true } 选项或在管道里加 $explain 观察,重点确认 $match 是否被推入索引扫描。