Interface ExplainOptions

When set, this configures an explain command. Valid values are boolean (for legacy compatibility, see ExplainVerbosityLike), a string containing the explain verbosity, or an object containing the verbosity and an optional maxTimeMS.

Examples of valid usage:

collection.find({ name: 'john doe' }, { explain: true });
collection.find({ name: 'john doe' }, { explain: false });
collection.find({ name: 'john doe' }, { explain: 'queryPlanner' });
collection.find({ name: 'john doe' }, { explain: { verbosity: 'queryPlanner' } });

maxTimeMS can be configured to limit the amount of time the server spends executing an explain by providing an object:

// limits the `explain` command to no more than 2 seconds
collection.find({ name: 'john doe' }, {
explain: {
verbosity: 'queryPlanner',
maxTimeMS: 2000
}
});
interface ExplainOptions {
    explain?: ExplainVerbosityLike | ExplainCommandOptions;
}

Hierarchy (view full)

Properties

Properties

Specifies the verbosity mode for the explain output.