[SERVER-13434] Record does not seem to be indexed correctly Created: 01/Apr/14 Updated: 10/Dec/14 Resolved: 01/Apr/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ian Martin | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
I have a record in my database but it doesn't seem to be indexed correctly. , and this is used to run the query. locobase:SECONDARY> db.history.find({device:357207050859404,"time":{"$gt":start,"$lt":end}}).explain() , note: there are 19 items found but if I give a hint to not use the time field in the index I get locobase:SECONDARY> db.history.find({device:357207050859404,"time":{"$gt":start,"$lt":end}}).hint( {device:1}).explain() , now there are 20 items. The missing item has as far as I know, There are no other records with this problem and everything else seems normal. |
| Comments |
| Comment by Ian Martin [ 01/Apr/14 ] |
|
Oh Yes, locobase:SECONDARY> db.history.find({device:357207050859404,"time":{"$gt":start,"$lt":end}}).count() ).count() however, I have a record without a time field which would explain that. I am still seeing fewer records from my java program though but that problem must be elsewhere. Sorry for the misleading report. |
| Comment by Andy Schwerin [ 01/Apr/14 ] |
|
Both plans return 19 results (n: 19). The first plan uses the more selective index to only examine the 19 matching documents, while the second plan uses the less selective index to visit the 20 documents matching the device component of the query, and then filters out the one of those 20 documents that does not match the time bounds. Can you confirm the values of the "start" and "end" times you're using? |