[SERVER-7595] indexOnly is never true when isMultiKey is true Created: 08/Nov/12 Updated: 10/Aug/14 Resolved: 08/Nov/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Diagnostics, Performance |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Harold Cooper | Assignee: | Aaron Staple |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Operating System: | ALL | ||||||||||||
| Participants: | |||||||||||||
| Description |
|
I've noticed that queries on a multiKey index are never indexOnly. Is that true? Seems odd. For example if you set up a table as follows:
Then querying on 'single' with a readset of just 'single' still gives indexOnly: false, even though the required data should certainly be available in the index:
I don't know if this is an actual performance issue or just a problem with explain(). (Note that this was originally a post in the Google Group, where Max Schireson said I should file a bug: https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/QsZFS4nddHo) |
| Comments |
| Comment by Harold Cooper [ 08/Nov/12 ] |
|
Ah, interesting, thanks for the explanation. |
| Comment by Aaron Staple [ 08/Nov/12 ] |
|
Hi Harold, Unfortunately the metadata stored about the index just has a single multikey flag, not a per field flag. It does not distinguish between cases where you've been inserting documents like this: {single: 'a', multi: [1,2,3]}or like this: {single: ['a','b','c'], multi: 1}As a result, covered index projections are never used for an index that is multikey on any field. We already have a ticket open for addressing this, Your example is one of the cases where you might want to have an index on both { single:1 }and { single:1, multi:1 }. If you have both of these indexes, you may need to explicitly hint the { single:1 } index to get indexOnly:true behavior. Making that happen automatically would be part of |