[SERVER-21785] Explain with shell can return misleading plan for unindexed sort queries that specify limit or batchSize Created: 07/Dec/15 Updated: 10/Feb/16 Resolved: 10/Feb/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Diagnostics, Querying, Shell |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | J Rassi | Assignee: | Tess Avitabile (Inactive) |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | ALL |
| Participants: |
| Description |
|
There are two issues with the shell's explain helper implementation:
As a result, in either of the above cases, the shell will issue a slightly different query to the server depending on whether or not explain is being used. Especially for queries that are sensitive to the value of "ntoreturn", an entirely different plan can be selected. For example, for unindexed sort queries that specify limit or batchSize:
Reproduce as follows:
At log level 1, the server generates the following log lines:
Notice that a single-leaf plan is chosen when explain() is used, and a two-leaf plan (the OR plan) is chosen when itcount() is used. Furthermore, notice that the "singleBatch" find command option is incorrectly added when explain() is used. |
| Comments |
| Comment by Tess Avitabile (Inactive) [ 10/Feb/16 ] | |
|
Issue (2) is fixed. Issue (1) will not be fixed due to the complexity that a fix would require. In versions after 3.0, we cannot accurately explain the query
in legacy read mode. This is because find in legacy read mode uses OP_QUERY, but explain against a version 3.0 server or greater uses the find command. OP_QUERY finds use an OR plan that uses a top-K sort for the first batch, and falls back to un-limited sort for subsequent batches. The find command cannot produce this query plan. | |
| Comment by Githook User [ 10/Feb/16 ] | |
|
Author: {u'username': u'tessavitabile', u'name': u'Tess Avitabile', u'email': u'tess.avitabile@mongodb.com'}Message: |