Skip to content

Instantly share code, notes, and snippets.

@alpenfritz
Forked from rantav/README.md
Created November 5, 2020 07:15
Show Gist options
  • Save alpenfritz/98b981581560408a0dc52fb7a8b02ba1 to your computer and use it in GitHub Desktop.
Save alpenfritz/98b981581560408a0dc52fb7a8b02ba1 to your computer and use it in GitHub Desktop.

Revisions

  1. @rantav rantav revised this gist Aug 25, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,8 @@ This presents a histogram of slow collections

    Histogram of the slowest collections (collections with the slowest queries) - number of millies spent in each collection
    ---
    > db.system.profile.group({key: {ns: true}, initial: {millis: 0}, reduce: function(obj, prev){ prev.millis += obj.millis;}})

    > db.system.profile.group({key: {ns: true}, initial: {millis: 0}, reduce: function(obj, prev){ prev.millis += obj.millis;}})

    Find the most recent slow query
    ---
  2. @rantav rantav revised this gist Aug 25, 2012. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -10,14 +10,23 @@ First, you have to enable profiling
    Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...


    Find the slowest collections (collections with the slowest queries)
    Histogram of the slowest collections (collections with the slowest queries) - number of queries per collection
    ---
    This presents a histogram of slow collections

    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

    Histogram of the slowest collections (collections with the slowest queries) - number of millies spent in each collection
    ---
    > db.system.profile.group({key: {ns: true}, initial: {millis: 0}, reduce: function(obj, prev){ prev.millis += obj.millis;}})
    Find the most recent slow query
    ---

    > db.system.profile.find().sort({$natural: -1}).limit(1)

    Find the single slowest query in the capped system.profile collection right now
    ---

    > db.system.profile.find().sort({millis: -1}).limit(1)

  3. @rantav rantav revised this gist Aug 25, 2012. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    A few show tricks to find slow queries in mongodb
    ===

    Enable profiling
    ==============
    ---
    First, you have to enable profiling

    > db.setProfilingLevel(1)
    @@ -10,7 +11,7 @@ Now let it run for a while. It collects the slow queries ( > 100ms) into a cappe


    Find the slowest collections (collections with the slowest queries)
    ===
    ---
    This presents a histogram of slow collections

    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})
  4. @rantav rantav revised this gist Aug 25, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -9,12 +9,14 @@ First, you have to enable profiling
    Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...


    == Find the slowest collections (collections with the slowest queries)
    Find the slowest collections (collections with the slowest queries)
    ===
    This presents a histogram of slow collections

    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

    == Find the most recent slow query
    Find the most recent slow query
    ---

    > db.system.profile.find().sort({$natural: -1}).limit(1)

  5. @rantav rantav revised this gist Aug 25, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    A few show tricks to find slow queries in mongodb

    =Enable profiling
    Enable profiling
    ==============
    First, you have to enable profiling

    > db.setProfilingLevel(1)
  6. @rantav rantav revised this gist Aug 25, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    A few show tricks to find slow queries in mongodb

    == Enable profiling
    =Enable profiling
    First, you have to enable profiling

    > db.setProfilingLevel(1)
  7. @rantav rantav revised this gist Aug 25, 2012. 2 changed files with 19 additions and 11 deletions.
    19 changes: 19 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    A few show tricks to find slow queries in mongodb

    == Enable profiling
    First, you have to enable profiling

    > db.setProfilingLevel(1)

    Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...


    == Find the slowest collections (collections with the slowest queries)
    This presents a histogram of slow collections

    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

    == Find the most recent slow query

    > db.system.profile.find().sort({$natural: -1}).limit(1)

    11 changes: 0 additions & 11 deletions mongo-shell.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +0,0 @@
    // enable profiling
    > db.setProfilingLevel(1)

    // let it run for a while

    // then find the slowest collections (collections with the slowest queries)
    // This presents a histogram of slow collections
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

    // find the most recent slow query:
    > db.system.profile.find().sort({$natural: -1}).limit(1)
  8. @rantav rantav revised this gist Aug 23, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mongo-shell.js
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@

    // then find the slowest collections (collections with the slowest queries)
    // This presents a histogram of slow collections
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}}
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}})

    // find the most recent slow query:
    > db.system.profile.find().sort({$natural: -1}).limit(1)
  9. @rantav rantav revised this gist Aug 23, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions mongo-shell.js
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,8 @@
    // let it run for a while

    // then find the slowest collections (collections with the slowest queries)
    // This presents a histogram of slow collections
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}}

    // find the most recent slow query:
    > db.system.profile.find().sort({$natural: -1}).limit(1)
  10. @rantav rantav revised this gist Aug 23, 2012. 2 changed files with 7 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}}
    7 changes: 7 additions & 0 deletions mongo-shell.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    // enable profiling
    > db.setProfilingLevel(1)

    // let it run for a while

    // then find the slowest collections (collections with the slowest queries)
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}}
  11. @rantav rantav created this gist Aug 23, 2012.
    1 change: 1 addition & 0 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    > db.system.profile.group({key: {ns: true}, initial: {count: 0}, reduce: function(obj,prev){ prev.count++;}}