<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    Finding slow queries in MongoDB

    Database Profiling

    MongoDB Profiler is a db profiling system that can help identify inefficient

    or slow queries and operations.

    Levels of profiles available are:

    Level

    Setting

    0

    Off. & No profiling

    1

    On & only includes slow operations

    2

    On & Includes all operations


    We can enable it by setting the Profile level value using the following
    command in mongo shell :

    "db.setProfilingLevel(1)"

    By default, mongod records slow queries to its log, as defined by slowOpThresholdMs.

    NOTE

    Enabling database profiler puts negative impact on MongoDB’s performance.

    It’s better to enable it for specific intervals & minimal on Production Servers.

    We can enable profiling on a mongod basis but This setting will not propagate
    across a replica set and sharded cluster.

    We can view the output in the system.profile collection in mongo shell using show profile command, or using following:

    db.system.profile.find( { millis : { $gt : 200 } } )

    Command returns operations that took longer than 200 ms. Similarly we
    can change the values as per our need.

    Enabling profile for an entire mongod instance.

    For the purpose of development in testing, we can enable database profiling/settings for an 
    entire mongod instance. The profiling level will be applied to all databases.

     

    NOTE:

    We can't enable the profiling settings on a mongos instance. To enable the profiling in

    shard clusters, we have to enable/start profiling for each mongod instance in cluster.

     

    Query for the recent 10 entries

    db.system.profile.find().limit(10).sort( { ts : 1 } ).pretty()

     

    Collection with the slowest queries(No. Of queries)

    db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

     

    Collection with the slowest queries(No. Of millis spent)

    db.system.profile.group({key: {ns: true}, initial: {millis: 0}, reduce: function(obj, prev){ prev.millis += obj.millis;}})

     

    Most recent slow query

    db.system.profile.find().sort({$natural: -1}).limit(1)

     

    Single slowest query(Right now)

    db.system.profile.find().sort({millis: -1}).limit(1)

    posted on 2020-03-27 23:35 paulwong 閱讀(309) 評論(0)  編輯  收藏 所屬分類: MONGODB

    主站蜘蛛池模板: 性一交一乱一视频免费看| 两个人看的www视频免费完整版| 久久久久久成人毛片免费看| 亚洲成av人片一区二区三区| 亚洲欧美日韩国产成人| 曰批视频免费30分钟成人| 亚洲A∨无码一区二区三区| a毛片久久免费观看| 久久亚洲精品视频| 手机看片国产免费永久| 久久精品国产亚洲麻豆| 99re在线免费视频| 亚洲国产精品综合久久2007| 亚洲免费观看在线视频| 亚洲免费福利视频| 国产精品视频免费一区二区| 亚洲人成网亚洲欧洲无码| 香蕉视频在线观看免费国产婷婷| 亚洲欧洲精品成人久久曰| 国产精品国产自线拍免费软件| 色吊丝免费观看网站| 亚洲综合激情另类专区| 国产一级淫片a免费播放口| 亚洲最大成人网色| 久久WWW免费人成人片| 精品久久亚洲一级α| 亚洲精品无码不卡在线播放HE| 日韩精品无码一区二区三区免费| 亚洲大香伊人蕉在人依线| 女人18毛片a级毛片免费| 日本精品久久久久久久久免费 | 亚洲精品欧美综合四区| 免费亚洲视频在线观看| 最近免费字幕中文大全| 亚洲国产精品日韩在线观看| 午夜一级免费视频| 中文字幕免费观看视频| 亚洲国产美女福利直播秀一区二区| 国产精品深夜福利免费观看 | jizz在线免费观看| 亚洲黄色免费在线观看|