[SERVER-15264] Dates shown in indexBounds are incorrect Created: 15/Sep/14 Updated: 02/Oct/14 Resolved: 01/Oct/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.6.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Riaz Ahmed | Assignee: | Ramon Fernandez Marina |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL | ||||||||||||||||||||||||||||
| Steps To Reproduce: |
|
||||||||||||||||||||||||||||
| Participants: |
| Description |
|
MongoDB shell shows incorrect date when explain() is run with find() query on an indexed Date field. 1. Simply fill a collection with 100 documents containing a date field
|
| Comments |
| Comment by Ramon Fernandez Marina [ 02/Oct/14 ] | |||||||||||||
|
Thanks riyyaz, although credit goes to david.storch – he's the one that crafted the explanation I posted above. | |||||||||||||
| Comment by Riaz Ahmed [ 02/Oct/14 ] | |||||||||||||
|
Thank you Ramon for your lucid explanation. Best Regards, | |||||||||||||
| Comment by Ramon Fernandez Marina [ 01/Oct/14 ] | |||||||||||||
|
riyyaz, this is the expected behavior. When you have a query {a: {$gt: b}} where the value of "b" is a date, this means that you should return all documents where "a" is a BSON element greater than "b", but also that "a" must be a date. These two conditions, converted into index bounds, give you the interval
The upper bound of the interval is simply the highest possible date value. So although it may look odd, as though a garbage date got displayed, this is in fact correct. A similar argument applies to the $lt case:
In this case, the left hand side of the interval is actually exclusive:
BSONType "true" is the type that compares just below BSONType date. The exclusive bound of "true" correctly leaves out all BSON elements that would compare less than the smallest date. Please see comparison sort order of BSON types for more information. Regards, |