[SERVER-35069] Explain should include command being explained Created: 18/May/18  Updated: 29/Oct/23  Resolved: 11/Nov/20

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Improvement Priority: Major - P3
Reporter: Chris Harris Assignee: Ruoxin Xu
Resolution: Fixed Votes: 0
Labels: QFB, asya, neweng, storch
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-37577 Explain should indicate when a hint i... Closed
Related
is related to SERVER-40905 Explain should indicate when aggregat... Backlog
Backwards Compatibility: Fully Compatible
Sprint: Query 2019-12-16, Query 2020-10-19, Query 2020-11-02, Query 2020-11-16
Participants:

 Description   

Updated summary:
Explain output include the full command which is being explained. This could be helpful in situations where explain plans are reviewed without having the originating command used to generated it.

Original description:
Similar to the indexFilterSet field, it may be worth having a flag to indicate what hint(), if any, was requested with the explain.  This could be helpful in situations where explain plans are reviewed without having the originating command used to generated it.



 Comments   
Comment by Githook User [ 10/Nov/20 ]

Author:

{'name': 'Ruoxin Xu', 'email': 'ruoxin.xu@mongodb.com', 'username': 'RuoxinXu'}

Message: SERVER-35069 Explain should include command being explained
Branch: master
https://github.com/mongodb/mongo/commit/afbc28ca7d7e5aae4eaff1609a55af8e79ef275f

Comment by James Wahlin [ 10/Dec/19 ]

Reviewing this again, our tentative plan to address will be to add the original command object to the explain output as a last step in the explain command. We will only add if doing so will not push the explain object over the 16MB limit. We can consider partial application of the original command message for future work. It will be tricky and potentially fragile as it will have to parse explain output with handling for each supported command.

When explain is run against mongos, only mongos should inject the original command as doing so at the shard level will record redundant information and make it much more likely that we will exceed the 16MB limit. Part of the work for this ticket will be to figure out how best to recognize this. 

Comment by Asya Kamsky [ 14/Mar/19 ]

I’m specifically thinking that explain of update is to see how the query portion is going to be executed. We don’t currently explain anything about applying the update part so it seems ... strange to include it.

Comment by Charlie Swanson [ 13/Mar/19 ]

asya why should we truncate the command if the explain is too large? Should we consider truncating 'rejectedPlans' instead? or perhaps 'serverInfo'? Choosing the command feels a little forced based on the fact that it's the latest addition - is it really the best place to trim?

Are you proposing just adding the name of the command and hint and then keeping things as-is so that the command fails if the result BSON is larger than 16MB?

Comment by Asya Kamsky [ 13/Mar/19 ]

charlie.swanson I think it’s fine/correct to exclude all the details of the command (maybe only if it’s big enough to blow out the limit). For instance for update we care about query portion not update portion. Aggregation could be very large but again just including which command is being run and whether a hint is specified is highest value.

Comment by Charlie Swanson [ 12/Jul/18 ]

We briefly started to implement this but then ran into some issues and adjusted course. One interesting note that came out of the progress here: If you're explaining a large command (for example a replace-mode update with a large document), we will potentially blow the 16MB document size limit by including the entire command in the output. It may be reasonable/acceptable to fail the operation in this case? Deserves some thought.

Comment by Chris Harris [ 25/May/18 ]

Great thought.  That sounds like a reasonable approach to me.  Feel free to change the title/description to match.  

Comment by David Storch [ 22/May/18 ]

Instead, should explain output include the full command which is being explained? That would prevent us from ever asking questions about the properties of the original command when it is not available.

Generated at Thu Feb 08 04:38:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.