有没有办法用runCommand
运行explain
?我有以下查询:
db.runCommand({geoNear:"Locations", near:[50,50], spherical:true})
我如何对其运行explain
?我想获得执行时间。
最佳答案
据我所知,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
-改为查询?这将使您能够完全访问 explain
。
关于mongodb - 如何 'explain' 一个runCommand?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17340183/