[SERVER-2831] For $or query, sparseness matching semantics for a document may be based on a sparse index even if a full index could be used Created: 24/Mar/11  Updated: 07/Dec/15  Resolved: 07/Dec/15

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

Type: Question Priority: Major - P3
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Comments   
Comment by David Storch [ 07/Dec/15 ]

This is fixed in 3.2:

> var t = db.jstests_orh;
> t.drop()
false
> t.ensureIndex( {a:1}, {sparse:true} );
> t.ensureIndex( {b:1,a:1} );
> t.save( {b:2} );
> t.count({a: null})
1
> t.count({a: null, b: 2})
1
> t.count( {$or:[{b:2,a:null},{a:null}]} )
1
> t.count( {$or:[{a:null},{b:2,a:null}]} )
1

I'm guessing that this was fixed as part of the query engine rewrite in 2.6, if not earlier.

Comment by Eliot Horowitz (Inactive) [ 24/Mar/11 ]

Not sure what the right answer, but putting in 1.9 so we make a decision.

Comment by Aaron Staple [ 24/Mar/11 ]

May be works as designed, but might be worth discussing.

Comment by Aaron Staple [ 24/Mar/11 ]

See jstests/orh.js for a demonstration of current behavior

Comment by auto [ 24/Mar/11 ]

Author:

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

Message: SERVER-2831 test/demonstration of current behavior
https://github.com/mongodb/mongo/commit/8004154cda5556e326bf97e14f847032fe3ef3ec

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