[SERVER-958] Range queries on arrays behave differently with indexes Created: 04/Apr/10  Updated: 12/Jul/16  Resolved: 16/May/11

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

Type: Bug Priority: Major - P3
Reporter: Mathias Stearn Assignee: Aaron Staple
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-1937 $gt/$lt/$ne with scalar operand yield... Closed
depends on SERVER-2864 query pattern cannot be created for a... Closed
depends on SERVER-2865 $or clause won't handle 'invalid' key... Closed
is depended on by SERVER-2165 $in and $all don't work together Closed
is depended on by SERVER-2302 if a field has a regular filter and $... Closed
is depended on by SERVER-1089 $and operator Closed
is depended on by SERVER-3102 invalidate querypattern when index be... Closed
Related
related to SERVER-3102 invalidate querypattern when index be... Closed
related to SERVER-3103 key check optimization for multikey i... Closed
related to SERVER-3104 index bound improvements for elemMatc... Closed
is related to SERVER-1932 range queries on arrays behave incons... Closed
Participants:

 Description   

> db.test.insert(

{a:[1,10]}

)
> db.test.find({a: {$gt: 2, $lt:5}})

{ "_id" : ObjectId("4bb9be0accf9c6e519c4d1fe"), "a" : [ 1, 10 ] }

> db.test.ensureIndex(

{a:1}

)
> db.test.find({a: {$gt: 2, $lt:5}})
>



 Comments   
Comment by Aaron Staple [ 16/May/11 ]

A few related todos

SERVER-3102
SERVER-3103
SERVER-3104

Comment by auto [ 02/May/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 Looser bounds for multikey indexes with parallel nested fields
Branch: master
https://github.com/mongodb/mongo/commit/e780ffc12fc56885566a93f5fa97f8281885f334

Comment by auto [ 02/May/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 Prefer fully contained multikey ranges since they are smaller.
Branch: master
https://github.com/mongodb/mongo/commit/4786360d414f6b4421a71456222866c9a4f033fa

Comment by auto [ 25/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 merge and address mongos dependency differences
Branch: master
https://github.com/mongodb/mongo/commit/3af50f5b941a07b0f290c7f8ee2726c85e2d0699

Comment by auto [ 25/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 merge and address mongos dependency differences
Branch: master
https://github.com/mongodb/mongo/commit/3af50f5b941a07b0f290c7f8ee2726c85e2d0699

Comment by auto [ 25/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 SERVER-2864 tests
Branch: master
https://github.com/mongodb/mongo/commit/8e92ba9ac0dfba5865810a1a26f5934d69e70fe3

Comment by auto [ 25/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 tests
Branch: master
https://github.com/mongodb/mongo/commit/870fedc9e1dea57532d109782b2a31378b32f16c

Comment by auto [ 25/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 Update matcher and matcher usage for better non single key range support
Branch: master
https://github.com/mongodb/mongo/commit/f799371da9b38f65b68abec09d4b9738fe6d1c66

Comment by auto [ 25/Apr/11 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-958 Track non single key field ranges and utilize them in query planning
Branch: master
https://github.com/mongodb/mongo/commit/a22732613243b36d91170d2ba6d5b492f36f3722

Comment by Eliot Horowitz (Inactive) [ 12/Oct/10 ]

Yes and Yes.

Comment by Aaron Staple [ 12/Oct/10 ]

If you want that to be the correct solution, then I don't think we'll ever be able to do a closed range index search on an index where multikeys are used. In the above example, we'd need to scan the index either for all documents where a < 5 or all documents where a > 2. Also, how should I pick which of those ranges to scan? Just use the first one?

Comment by Eliot Horowitz (Inactive) [ 12/Oct/10 ]

Without the index is correct.

Comment by Aaron Staple [ 12/Oct/10 ]

Ok - which is the correct result? The one with the index or without?

Comment by Jerry [ 03/Oct/10 ]

Nevermind on my last comment.

Comment by Jerry [ 03/Oct/10 ]

The possible workaround thus far:

> db.test.find({a:{$lt:5, $not:{$gte:2}}})

I believe the technical term for this is "hax!"

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