How do I check if an index is being used

后端 未结 2 1085
梦如初夏
梦如初夏 2020-12-08 20:10

I have a mongodb replica set with a lot of databases, collections & indexes.

We did a lot of refactor and optimization and, of course, I have a lot of \"creative

2条回答
  •  不思量自难忘°
    2020-12-08 21:00

    There is a pretty cool script out on Github that you should look at:

    https://github.com/wfreeman/indexalizer

    Basically it involves turning on profiling for your database and then it will use the data collected by the profiler to drive explain() calls. It then tells you both which indexes are not being used and which queries are not using indexes. Pretty slick.

    More about mongoDB database profiling:

    http://docs.mongodb.org/manual/reference/database-profiler/

提交回复
热议问题