衡量索引使用
在本页面
db.orders.aggregate( [ { $indexStats: { } } ] )
也可参考:
在executionStats 模式中使用
db.collection.explain()
或cursor.explain()
方法返回关于查询过程的统计信息,包括使用的索引、扫描的文档数量以及查询处理所用的时间(以毫秒为单位)。也可参考:
代码示例如下:
db.people.find(
{ name: "John Doe", zipcode: { $gt: "63000" } }
).hint( { zipcode: 1 } )
db.people.find(
{ name: "John Doe", zipcode: { $gt: "63000" } }
).hint( { zipcode: 1 } ).explain("executionStats")
db.people.explain("executionStats").find(
{ name: "John Doe", zipcode: { $gt: "63000" } }
).hint( { zipcode: 1 } )
db.people.find(
{ name: "John Doe", zipcode: { $gt: "63000" } }
).hint( { $natural: 1 } )
译者:程哲欣