怎么将mongodb里面的sql操作记录下来

2025-04-26 16:27:00
推荐回答(1个)
回答1:

准备
在此之前,我们先在我们的数据库中插入10万条数据。数据的格式是这样的:
?

1
2
3
4
5
6

{
"name":"your name",
"age":22,
"gender":"male",
"grade":2
}

explain
explain方法是用来查看db.collecion.find()的一些查询信息的。例如:
?

1

db.collectionName.find().explain()

explain方法有个可选的参数verbose,是个字符串,他表示的是verbose的模式。一共分为3种模式:
queryPlanner:默认参数,详细说明查询优化器选择的计划并列出