<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

    主站蜘蛛池模板: 亚洲综合色一区二区三区小说| 美女啪啪网站又黄又免费| 久久精品无码精品免费专区| 综合亚洲伊人午夜网 | 一边摸一边桶一边脱免费视频| 日韩电影免费在线观看视频| 亚洲六月丁香婷婷综合| 亚洲色丰满少妇高潮18p| 亚洲成在人线aⅴ免费毛片| 亚洲一卡2卡4卡5卡6卡残暴在线| 84pao国产成视频免费播放| 亚洲一区二区三区久久久久| 在线免费观看毛片网站| 99亚洲乱人伦aⅴ精品| 亚洲无码视频在线| 在线播放免费人成毛片乱码| 亚洲精品在线免费观看| 成年美女黄网站18禁免费| 久久久久亚洲AV无码去区首| 最近免费mv在线观看动漫 | 最近2019中文免费字幕在线观看| 午夜亚洲AV日韩AV无码大全| 四虎在线成人免费网站| 亚洲国产精品成人精品小说| 18禁美女黄网站色大片免费观看| 亚洲成年人电影在线观看| 日韩精品视频免费观看| rh男男车车的车车免费网站| 久久亚洲精品成人av无码网站| 亚洲综合色一区二区三区| 亚洲AV之男人的天堂| 国产好大好硬好爽免费不卡| 亚洲av永久无码精品三区在线4| 免费国产人做人视频在线观看| 亚洲香蕉久久一区二区| 成年女人永久免费观看片| 99久久免费国产精品热| 亚洲乱码一二三四区麻豆| 亚洲综合亚洲综合网成人| 亚欧色视频在线观看免费| 免费无码专区毛片高潮喷水|