The planCacheListPlans command is useful for displaying cached candidate plans for a given query shape, which is specified by query, sort and projection parameters. However, the query shape will often be collected from the planCacheListQueryShapes command, which returns an array of objects. This makes it difficult to pass the results directly to planCacheListPlans (although they can be copy/pasted).
Currently, the workflow may look something like this:
db.runCommand({planCacheListQueryShapes:'collectionName'}); ... <copy the fields of the shape object> ... db.runCommand({planCacheListQueryShapes:'collectionName', <paste the shape object fields>});
or
var shape = db.runCommand({planCacheListQueryShapes:'collectionName'}).shapes[0]; db.runCommand({planCacheListPlans:'collectionName', query: shape.query, sort: shape.sort, projection: shape.projection});
To simplify automation and usability, it would be helpful to allow planCacheListQueryShapes to accept an object with query/sort/projection fields instead of individual parameters; e.g.:
var shape = db.runCommand({planCacheListQueryShapes:'collectionName'}).shapes[0]; db.runCommand({planCacheListQueryShapes:'collectionName', shape});