[SERVER-99] query optimizer scans object without indexed field in 1 direction Created: 06/Jun/09  Updated: 12/Jul/16  Resolved: 22/Jul/09

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

Type: Bug Priority: Major - P3
Reporter: Eliot Horowitz (Inactive) Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

see jstests/index_check3.js



 Comments   
Comment by Eliot Horowitz (Inactive) [ 22/Jul/09 ]

add other types in subcase

Comment by Aaron Staple [ 22/Jul/09 ]

Um, the designated 'correct' solution doesn't avoid scanning null values when the query is not a number, for example see new end of index_check3.js.

Comment by Eliot Horowitz (Inactive) [ 10/Jul/09 ]

closed since 0.9.6 went out

Comment by Eliot Horowitz (Inactive) [ 02/Jul/09 ]

correct solution is to change FieldBoundSet computation
right now { a :

{ $lt : a }

} is MinKey ->

{ a : 1 }


needs to be

{ a : MIN_DOUBLE }

->

{ a : 1 }
Comment by Aaron Staple [ 08/Jun/09 ]

So if you want to do a real fix, you can have the index scanning code skip indexed nulls when answering certain types of queries. This would tie in with the work on SERVER-100.

Comment by Eliot Horowitz (Inactive) [ 08/Jun/09 ]

right - that's the issue we need to fix

Comment by Aaron Staple [ 08/Jun/09 ]

The issue here is that a missing field gets a value of 'null' in the index, but the matcher does not allow a missing value to satisfy

{ $gt: 50 }

or

{ $lt: 50 }

.
For a quick fix you can make the test pass by replacing the last line with the following:

assert.gt( 30 , t.find( { foo :

{ $gt : 50, $lt: 100 }

} ).explain().nscanned , "gt" )

which prevents index scanning of the null range

Generated at Thu Feb 08 02:53:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.