How to find queries not using indexes or slow in mongodb

后端 未结 6 1339
轻奢々
轻奢々 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:24

    You can use the following two mongod options. The first option fails queries not using index (V 2.4 only), the second records queries slower than some ms threshold (default is 100ms)

    --notablescan
    
    Forbids operations that require a table scan.
    
    --slowms 
    
    Defines the value of “slow,” for the --profile option. The database logs all slow queries to the log, even when the profiler is not turned on. When the database profiler is on, mongod the profiler writes to the system.profile collection. See the profile command for more information on the database profiler.
    

提交回复
热议问题