[SERVER-37308] Log queries with high ratio of scanned / returned Created: 25/Sep/18  Updated: 06/Dec/22  Resolved: 23/Sep/20

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Tomer Yakir Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 27
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-49102 Accept a filter expression as an alte... Closed
Related
related to SERVER-14432 Flexible logging of certain queries Closed
Assigned Teams:
Query
Participants:
Case:

 Description   

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]},
    ]}}
})



 Comments   
Comment by David Percy [ 23/Sep/20 ]

This is possible now, with SERVER-49102 fixed. I've updated the ticket description with an example.

Comment by Sergio Castro [ 01/Mar/19 ]

+1

Generated at Thu Feb 08 04:45:37 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.