[SERVER-9532] incorrect elemMatch bounds for multi key compound index Created: 01/May/13 Updated: 11/Jul/16 Resolved: 10/Feb/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.4.3 |
| Fix Version/s: | 2.6.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Dominik Gehl | Assignee: | David Storch |
| Resolution: | Done | Votes: | 0 |
| Labels: | query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux 64bit |
||
| Attachments: |
|
| Operating System: | ALL |
| Steps To Reproduce: | create index on aH.uid > db.testing_ah_array_path_new.find({'aH.sm':'dominik','aH.uid':{'$gte':1, '$lte':1000}}).explain() , On the other hand, when changing the '$lte' and '$gte' order > db.testing_ah_array_path_new.find({'aH.sm':'dominik','aH.uid':{'$lte':1000,'$gte':1}}).explain() , In both cases, upper and lower bound should be shown as set to 1 and 1000 respectively by explain() |
| Participants: |
| Description |
|
only the first of the '$lte' and '$gte' boundaries is actually used by the query optimizer. Order of '$lte' and '$gte therefore becomes crucial |
| Comments |
| Comment by Githook User [ 10/Feb/14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}Message: The new query system multikey index bounds behavior now largely matches that of 2.4. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Benety Goh [ 30/Oct/13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
smoke test script to reproduce/illustrate issue | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dominik Gehl [ 08/May/13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Reading through some more tickets, I found https://jira.mongodb.org/browse/SERVER-4155 and https://jira.mongodb.org/browse/SERVER-4180. So I started experimenting with the '$elemMatch' "solution"/workaround:
So, that works for a simple index ... unfortunately though, when having a compound index, it doesn't work any more
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dominik Gehl [ 02/May/13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Some more details on the specifics and also easy steps to reproduce:
So the problem happens as soon as at least two values are inserted into uid for one document. The index then becomes a multi-key index and the indexBounds are calculated differently |