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

    主站蜘蛛池模板: 亚洲精品视频观看| 一级毛片免费不卡直观看| 黄a大片av永久免费| 久久国产福利免费| 亚洲日产2021三区在线| 日韩精品亚洲专区在线观看| av永久免费网站在线观看 | 亚洲经典在线中文字幕| 成人免费淫片在线费观看| 99视频免费在线观看| 亚洲乱色熟女一区二区三区蜜臀| 久久久亚洲精品蜜桃臀| 国产免费看JIZZ视频| 男女一边摸一边做爽的免费视频| 亚洲成人激情小说| 亚洲国产综合无码一区| 免费无码又爽又刺激毛片| 无码人妻精品中文字幕免费 | 亚洲色偷偷综合亚洲AV伊人蜜桃 | 久久精品国产96精品亚洲 | 久久精品无码专区免费东京热| 美女被免费网站在线视频免费 | 国产精品亚洲二区在线观看| 国产一卡二卡3卡四卡免费| 中文字幕在线免费视频| 国产精品亚洲专区无码WEB| 亚洲熟妇av一区| 亚洲熟妇中文字幕五十中出| 免费观看美女裸体网站| 蜜桃AV无码免费看永久| 99re6在线视频精品免费| 美女视频黄a视频全免费网站一区| 亚洲天堂中文字幕在线观看| 国产亚洲3p无码一区二区| 亚洲AV无码之日韩精品| 在线免费观看一级片| 亚洲天堂免费在线| 91精品国产免费入口| 久别的草原电视剧免费观看| jizz免费观看| 一个人看的www在线免费视频 |