有没有办法在runCommand上运行explain?我有以下疑问:
db.runCommand({geoNear:"Locations", near:[50,50], spherical:true})如何在其上运行explain?我想知道执行时间。
发布于 2013-06-27 18:25:35
据我所知,explain是游标上的一个方法。但是,您可以启用integrated mongodb profiler
db.setProfilingLevel(2); // log all operations
db.setProfilingLevel(1, 50); // log all operations longer than 50msecs这会将nscanned、nreturned等详细信息记录到一个名为system.profile的封顶集合中,但不会像explain()调用那样提供更多详细信息。
在这种情况下是,但是,我认为有可能将runCommand改为$near-query?这将使您能够完全访问explain。
发布于 2013-06-27 18:28:48
我想我们不能为runCommand做解释。一些runCommand会自动为您提供统计数据(例如,distinct命令: db.runCommand({distinct:'test',key:'a'})
但是,您可以借助查询分析器。
db.setProfilingLevel(2)运行该查询后,关闭探查器,并检查该查询的system.profile集合。
发布于 2020-04-30 21:48:32
根据explain docs的说法,您可以简单地:
db.runCommand({
explain: {geoNear:"Locations", near:[50,50], spherical:true}
})https://stackoverflow.com/questions/17340183
复制相似问题