[SERVER-20066] Query planner should consider index scans on empty query predicates Created: 20/Aug/15 Updated: 08/Nov/22 Resolved: 20/Jun/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Performance, Querying |
| Affects Version/s: | 3.0.5 |
| Fix Version/s: | 3.5.9 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Kyle Suarez |
| Resolution: | Done | Votes: | 1 |
| Labels: | bi-performance, optimization | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||
| Sprint: | Query 2017-05-08, Query 2017-05-29, Query 2017-06-19, Query 2017-07-10 | ||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||||||||||
| Linked BF Score: | 0 | ||||||||||||||||||||||||||||||||
| Description |
| Comments |
| Comment by Kyle Suarez [ 13/Jul/18 ] |
Yes, that's correct. The query planner will always assume that an index scan is better than a collection scan.
Correct. This is the code that was added to generate these plans; it then falls through to the rest of the query planning logic: https://github.com/mongodb/mongo/blob/1345c0476cf47d691e8db532967238800d0a70c2/src/mongo/db/query/query_planner.cpp#L1005-L1037 |
| Comment by Chris Harris [ 13/Jul/18 ] |
|
With respect to the expected behavior of this ticket, the case description says that the planner should "consider" index scans on empty query predicates. My impression of the current behavior in the general case is that if a valid index scan plan is generated then it will always be used instead of a collection scan plan. Is that the case here as well? Or, said another way, does this ticket simply enable the generation of index scan plans (for empty predicate queries when the internal parameter is enabled), and the rest of the plan selection process is unchanged for these plans afterwards? |
| Comment by Githook User [ 20/Jun/17 ] |
|
Author: {u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}Message: Users can enable this behavior by turning on the |
| Comment by Kyle Suarez [ 15/Jun/17 ] |
|
Re-opening this ticket, as we want to place this behavior behind a query knob for now. |
| Comment by Githook User [ 07/Jun/17 ] |
|
Author: {u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}Message: |