[SERVER-2953] Use dotted indexes for embedded document queries Created: 14/Apr/11 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Alvin Richards (Inactive) | Assignee: | Backlog - Query Optimization |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | query, rewrite | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||
| Description |
|
Setup:
Using the dot-notation, the explain plan shows that the index is used:
However, expressing the query with a document results in the index not being used:
If there are indexed fields representing any of embedded fields in the query, in dot-notation, they should be used. This can be done to filter out the documents needed before the exact embedded document matching is done for the actual query criteria. |
| Comments |
| Comment by Asya Kamsky [ 09/Oct/17 ] |
|
|
| Comment by Gaetan Voyer-Perrault [ 15/Apr/11 ] |
|
Sample script (for clarification / unit test purposes): } ) } ) ) // query #1 ).explain().cursor // query #2 } ).explain().cursor ------ It looks like this logic may be missing when selecting an index for the query. For this bug to be fixed I would expect the output of #1 and #2 to be the same. |