<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 閱讀(306) 評論(0)  編輯  收藏 所屬分類: MONGODB

    主站蜘蛛池模板: 日本亚洲欧洲免费天堂午夜看片女人员 | 亚洲成AV人片高潮喷水| 1000部禁片黄的免费看| 亚洲AV无码一区二区三区系列 | 区久久AAA片69亚洲| a一级毛片免费高清在线| 亚洲AV无码乱码在线观看性色扶| 美女被爆羞羞网站免费| 亚洲精品国产自在久久| 精品免费久久久久国产一区| 在线观看亚洲av每日更新| 中文字幕视频免费在线观看| 亚洲国产精品久久久天堂| 日韩精品无码免费一区二区三区| 亚洲国产国产综合一区首页| 亚洲一区二区三区免费观看| 亚洲国产精品一区二区三区在线观看| 午夜免费福利在线观看| 香港一级毛片免费看| 国产亚洲人成无码网在线观看| 人妻无码久久一区二区三区免费| 亚洲欧洲日产国产最新| 免费电影在线观看网站| 香港一级毛片免费看| 久久精品亚洲一区二区| 日韩av无码成人无码免费| 日韩精品亚洲专区在线影视| 精品国产亚洲一区二区在线观看| 精品亚洲永久免费精品 | 美女被爆羞羞网站免费| 亚洲成av人在线视| 一个人免费观看视频www| 国产亚洲视频在线观看| 国产AV无码专区亚洲AV毛网站| 91成年人免费视频| 色婷婷综合缴情综免费观看| 亚洲成AV人在线观看天堂无码| 毛片a级三毛片免费播放| 一边摸一边桶一边脱免费视频| 7777久久亚洲中文字幕蜜桃 | 大学生a级毛片免费观看|