<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

    主站蜘蛛池模板: 亚洲AV成人无码天堂| 99国产精品永久免费视频| 亚洲精品一二三区| 好看的亚洲黄色经典| 白白色免费在线视频| 亚洲国产日韩在线| 亚洲成AV人片在线观看ww| 亚洲国产一区二区三区| 成人免费视频一区二区三区| 一级毛片免费观看不卡视频| 黄色短视频免费看| 男女啪啪免费体验区| 亚洲精品国产首次亮相| 亚洲国产亚洲片在线观看播放| 亚洲av色福利天堂| 亚洲色精品88色婷婷七月丁香| 亚洲成av人片在线观看天堂无码| 午夜成人免费视频| 成人A级毛片免费观看AV网站| 中文字幕天天躁日日躁狠狠躁免费| 两个人看www免费视频| 亚洲欧洲日产国码久在线观看| 无码人妻一区二区三区免费| 在线观看永久免费| 亚洲午夜免费视频| 欧洲精品99毛片免费高清观看| 拍拍拍无挡视频免费观看1000| 中文精品人人永久免费| 中文字幕免费在线视频| 久久国产一片免费观看| caoporm碰最新免费公开视频| 人妻仑刮八A级毛片免费看| 极品美女一级毛片免费| 黄网站色视频免费看无下截| 牛牛在线精品免费视频观看| 免费无码婬片aaa直播表情| 成人免费视频一区二区| 亚洲欧洲尹人香蕉综合| 亚洲国产韩国一区二区| 亚洲人成网男女大片在线播放| 亚洲13又紧又嫩又水多|