Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-37308

Log queries with high ratio of scanned / returned

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Logging
    • None
    • Query

      We should log queries with high ratio of scanned / returned regardless of their execution time to help find inefficient queries.


      This is now possible with SERVER-49102 fixed. Each database can be configured with a filter (a query predicate) that controls which operations are logged.

      For example, this filter will log queries where the ratio of index keys examined to documents returned is greater than 100:

      db.setProfilingLevel(0, {filter:
          {$expr: {$gt: [
              "$keysExamined",
              {$multiply: ["$nreturned", 100]},
          ]}}
      })
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            tomer.yakir@mongodb.com Tomer Yakir
            Votes:
            27 Vote for this issue
            Watchers:
            45 Start watching this issue

              Created:
              Updated:
              Resolved: