How to find queries not using indexes or slow in mongodb

后端 未结 6 1337
轻奢々
轻奢々 2020-12-08 05:00

is there a way to find queries in mongodb that are not using Indexes or are SLOW? In MySQL that is possible with the following settings inside configuration file:

         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 05:33

    In case somebody ends up here from Google on this old question, I found that explain really helped me fix specific queries that I could see were causing COLLSCANs from the logs.

    Example:

    db.collection.find().explain()

    This will let you know if the query is using a COLLSCAN (Basic Cursor) or an index (BTree), among other things.

    https://docs.mongodb.com/manual/reference/method/cursor.explain/

提交回复
热议问题