-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Index Maintenance, Querying
-
None
-
Fully Compatible
Right now it's easy to specify a query that will scan a range on an index:
index { a:1 } query { a:{ $gte:5, $lte:10 } }
or a set of points on an index:
index { a:1 } query { a:{ $in:[ 1, 2 ] } }
Using a regular expression it is also possible to specify certain combinations of ranges on an index:
index { a:1 } query { a:{ $in:[ /^x/, /^y/ ] } }
This ticket represents functionality for easily specifying more than one arbitrary range on a single index, scanned efficiently by the query optimizer. For example on
index { a:1 }: 1) query { $or:[ { a:{ $gte:5, $lte:10 } }, { a:{ $gte:100 } } ] } 2) query { a:{ $in:[ { $gte:5, $lte:10 }, { $gte:100 } ] } }
Example 1 is not currently optimized to work as a single index scan because $or is only implemented to support more general cases where or clauses may use different indexes.
Example 2 is not an allowed query currently.
- duplicates
-
SERVER-12594 subtrees of and/or can reduce to ixscans
- Backlog
- is duplicated by
-
SERVER-6200 some $or queries not optimized properly
- Closed