-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Optimization
-
None
-
3
-
TBD
-
None
-
None
-
None
-
None
-
None
-
None
-
None
We would like some way to verify that the plan cache and query planner index eligibility checks agree. That is, if the query planner determines that an index is ineligible for the query, then the plan cache also thinks the index is ineligible.
There are a couple of high-effort ways to do this: a refactor of both the plan cache and query planner to share index eligibility logic, or a PBT in C++ or Javascript that allows us to test the property (this would either require SERVER-107773 or some way to expose plan cache index eligibility results e2e).
This ticket represents a lighter-weight option: a debug-only check that verifies at planning time that the planner and plan cache agree on the index eligibility for the particular query being planned. (We probably also want a corresponding check within the plan cache). For example, we could hook in here, where we get the list of eligible indexes.
Some challenges with this ticket:
- The plan cache doesn't expose index eligibility information in an informative way right now. Based on the plan cache key, it is difficult to answer the question, "Is this query eligible for this index?". This ticket will need to introduce some way to compare eligibility between the query planner and plan cache formats WITHOUT changing how plan cache key computation works today (an unnecessary risk)
- The property mentioned above may not be true within sub-planning. For this initial ticket, we may want to avoid making the assertions within sub-planning.
If this proves much too difficult, then a simpler approach could be a debug-only check just in the plan cache code to do some last-minute verification on the index being used for the query. This could involve mock-query-planning with the given index to see if the planner considers it eligible, or something even simpler (such as re-verifying the collations match).
- is related to
-
SERVER-92806 Plan cache entry ignores index collation with $elemMatch, causing incorrect query results
-
- Closed
-
-
SERVER-107773 Support property testing in C++
-
- Needs Scheduling
-