[SERVER-17076] Consider removing IndexBounds::isSimpleRange Created: 27/Jan/15  Updated: 17/Feb/15  Resolved: 17/Feb/15

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

Type: Task Priority: Minor - P4
Reporter: David Storch Assignee: David Storch
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-9547 min() / max() with descending order s... Closed
Participants:

 Description   

The query system's index bounds representation has a few special cases in which it represents the bounds as a "simple range" (see code here). In particular, the simple range representation is used for $min/$max and some internal plans. We may be able to simplify the code by removing this special case and always using the regular representation for index bounds.



 Comments   
Comment by David Storch [ 17/Feb/15 ]

After some further thought, I believe that IndexBounds::isSimpleRange remains necessary in order to support the $min/[$max|http://docs.mongodb.org/manual/reference/operator/meta/max/] query operators. Simple range index bounds are capable of representing index ranges that are not otherwise representable using the normal index bounds format. Consider the following shell session:

> t.drop()
true
> t.insert({a: 1, b: 5})
WriteResult({ "nInserted" : 1 })
> t.insert({a: 2, b: 2})
WriteResult({ "nInserted" : 1 })
> t.ensureIndex({a: 1, b: 1})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> t.find().min({a: 1, b: 3}).max({a: 2, b: 3})
{ "_id" : ObjectId("54e3a343ca1dc479b4cf933c"), "a" : 1, "b" : 5 }
{ "_id" : ObjectId("54e3a348ca1dc479b4cf933d"), "a" : 2, "b" : 2 }
> t.find({a: {$gte: 1, $lte: 2}, b: 3}) // Returns no results

This demonstrates that the range specified by .min({a: 1, b: 3}).max({a: 2, b: 3}) cannot be represented as the combination of bounds on a and bounds on b.

Closing as Works as Designed.

Generated at Thu Feb 08 03:43:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.