<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

    主站蜘蛛池模板: 毛片a级毛片免费播放100| 亚洲最大av无码网址| 日韩一级片免费观看| 亚洲日韩乱码中文无码蜜桃臀网站 | 99re6在线视频精品免费下载| 精品亚洲AV无码一区二区| 免费在线黄色网址| 久久国产乱子免费精品| 亚洲熟妇AV日韩熟妇在线| 亚洲综合色婷婷七月丁香| 和日本免费不卡在线v| 一级毛片大全免费播放| 亚洲成年人免费网站| 亚洲精品岛国片在线观看| 99久久免费国产香蕉麻豆 | 8888四色奇米在线观看免费看| 亚洲成在人线在线播放无码| 国产亚洲人成网站在线观看不卡| 成年美女黄网站18禁免费| 最近免费中文字幕MV在线视频3| 亚洲国产精品综合久久网各| 久久久久无码专区亚洲av | 亚洲国产成人超福利久久精品 | 亚洲精品V天堂中文字幕| 亚洲五月激情综合图片区| 四虎成人精品在永久免费| 91精品成人免费国产片| 国产美女视频免费观看的网站| 亚洲午夜无码毛片av久久京东热 | 亚洲熟妇无码八V在线播放| 亚洲av无码潮喷在线观看| 亚洲?v无码国产在丝袜线观看| 2021国产精品成人免费视频| 成全视频在线观看免费| 婷婷亚洲综合五月天小说在线| 亚洲宅男精品一区在线观看| 亚洲AV日韩AV永久无码绿巨人 | 国产人成免费视频网站| a级毛片免费在线观看| 免费无码午夜福利片69| 亚洲AV成人影视在线观看|