[SERVER-6200] some $or queries not optimized properly Created: 25/Jun/12 Updated: 07/Mar/14 Resolved: 26/Feb/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.0.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Björn Karge | Assignee: | Aaron Staple |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
all |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
The execution plan generated for certain $or queries is amendable: > db.domain.ensureIndex( { key: 1 } ) }, { key: { $gte: 722156333548, $lt: 722156349325 }}, { key: { $gte: 722156416434, $lt: 722156433211 } }, } ===> { clauses: [ }, }, }, } ], This is according to the docs but slow, nonetheless. I would expect the following plan { cursor: "BtreeCursor key_1 multi", ..., indexBounds: { key: [ [ -922337203685477, -922337203685477 ], [ -230584300921369, -230584300921369 ], [ -154023107256070, -154023107256070 ], [ 722156315770, 722156332548 ], [ 722156333548, 722156349325 ], [ 722156416434, 722156433211 ], [ 115292150460684, 115292150460684 ], [ 153726349067734, 153726349067734 ], [ 461172215037663, 461172215037663 ] ] }} Which would almost halve the execution time (measured against a modified mongod where I patched the optimizer). Instead of modifying the optimizer, an alternative could also be to extend $in to accept ranges as well. |
| Comments |
| Comment by Aaron Staple [ 26/Feb/13 ] |
|
Hi Bjorn - I filed a ticket for this |
| Comment by Björn Karge [ 21/Feb/13 ] |
|
Added the patch I mentioned on |