[SERVER-78468] Single interval query keysExamined information is inaccurate Created: 27/Jun/23  Updated: 27/Oct/23  Resolved: 11/Jul/23

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

Type: Bug Priority: Major - P3
Reporter: Chao Yin Assignee: Backlog - Query Execution
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

Create a replica set.

use mydb;
 
db.coll.createIndex({a:1});
 
db.coll.insert({a:1})
 
db.coll.insert({a:false})
 
db.coll.insert({a: ""})
 
db.coll.find({a:{$gte:1}}).explain("allPlansExecution"); //  keysExamined = 1
 
db.coll.find({a: {$in:[1, 2]} }).explain("allPlansExecution"); //  keysExamined = 2

The above two queries should scan 2 documents:

{a:1}

and

{a: ""}

But the single interval query will only show keysExamined as 1.

 

Participants:

 Description   

When using a single interval query, the number of scanned keys displayed by explain is inaccurate. 

If the traversed data no longer meets the requirements , and the returned kv is empty code.

keysExamined will not increase. code

But multi-range queries use other methods to check bounds code

keysExamined data can be counted correctly.

 

 



 Comments   
Comment by Chao Yin [ 19/Jul/23 ]

Thank you for your reply!

Comment by Kyle Suarez [ 11/Jul/23 ]

This is not a bug and known behavior: see for example this test.

In the classic engine, we expect to scan more keys, but starting in v6.3, this query will use the new slot-based execution engine and scan a different amount. Note that a different number of keys examined is an implementation detail of the execution engine and not indicative of a bug.

Generated at Thu Feb 08 06:38:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.