[SERVER-11839] index is not used to provide sort for $not query Created: 23/Nov/13 Updated: 11/Jul/16 Resolved: 04/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | 2.5.5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Paul Klimashkin | Assignee: | Benety Goh |
| Resolution: | Done | Votes: | 0 |
| Labels: | query, query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7, Gentoo |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
explain output from 2.5.4 indicates that an in-memory sort (scanAndSort=true) is used to order results of $not query. The result set is large enough that it is hitting the internal limit of the in-memory sort - see assertion message. This is different from 2.5.3 where the query optimizer is able to utilize the index (scanAndSort=false). After updating from 2.5.3 to 2.5.4 start to get error messages for quires with sorting: query: , { r1: 3, s: { $ne: 9 }} ] }).sort( {sdate: -1}, {_id:0, cid: 1}).limit(30).explain()}} indexes , "name" : "sdate_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } , "name" : "r0_1", "ns" : "pastvu.photos", "sparse" : true, "background" : true, "safe" : null } , "name" : "r1_1", "ns" : "pastvu.photos", "sparse" : true, "background" : true, "safe" : null } , "name" : "r2_1", "ns" : "pastvu.photos", "sparse" : true, "background" : true, "safe" : null } , "name" : "r3_1", "ns" : "pastvu.photos", "sparse" : true, "background" : true, "safe" : null } , "name" : "r4_1", "ns" : "pastvu.photos", "sparse" : true, "background" : true, "safe" : null } , "name" : "s_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } , "name" : "r0_1_sdate_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } , "name" : "r1_1_sdate_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } , "name" : "r2_1_sdate_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } , "name" : "r3_1_sdate_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } , "name" : "r4_1_sdate_1", "ns" : "pastvu.photos", "background" : true, "safe" : null } 2.5.3: , { "$minElement" : 1 } ] 2.5.4: |