Module: Mongo::Collection::View::Explainable

Included in:
Mongo::Collection::View, Aggregation
Defined in:
build/ruby-driver-master/lib/mongo/collection/view/explainable.rb

Overview

Defines explain related behavior for collection view.

Since:

  • 2.0.0

Constant Summary collapse

QUERY_PLANNER =

The query planner verbosity constant.

Since:

  • 2.2.0

'queryPlanner'.freeze
EXECUTION_STATS =

The execution stats verbosity constant.

Since:

  • 2.2.0

'executionStats'.freeze
ALL_PLANS_EXECUTION =

The all plans execution verbosity constant.

Since:

  • 2.2.0

'allPlansExecution'.freeze

Instance Method Summary collapse

Instance Method Details

#explain(**opts) ⇒ Hash

Get the query plan for the query.

Examples:

Get the query plan for the query with execution statistics.

view.explain(verbosity: :execution_stats)

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (**opts):

  • :verbose (true | false)

    The level of detail to return for MongoDB 2.6 servers.

  • :verbosity (String | Symbol)

    The type of information to return for MongoDB 3.0 and newer servers. If the value is a symbol, it will be stringified and converted from underscore style to camel case style (e.g. :query_planner => “queryPlanner”).

Returns:

  • (Hash)

    A single document with the query plan.

See Also:

Since:

  • 2.0.0



59
60
61
# File 'build/ruby-driver-master/lib/mongo/collection/view/explainable.rb', line 59

def explain(**opts)
  self.class.new(collection, selector, options.merge(explain_options(**opts))).first
end