Sha256: 4963daea1f587eb7a6590a0f223423ed690df1e67d76c25abb95f23a916d591b

Contents?: true

Size: 808 Bytes

Versions: 1

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

module MongoClarify
  class Investigate
    def initialize(explain)
      @explain = explain
    end

    def operation_method
      case @explain
      in { queryPlanner: { winningPlan: { stage: 'COLLSCAN' } } }
        'Collection Scan'
      in { queryPlanner: { winningPlan: { stage: 'FETCH', inputStage: { stage: 'IXSCAN', indexName: index_name } } } }
        "Index Scan (Index Name: #{index_name})"
      else
        nil
      end
    end

    def execution_stats
      case @explain
      in { executionStats: { nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs } }
      else
        return
      end
      { n_returned: n, execution_time_millis: msec, total_keys_examined: keys, total_docs_examined: docs }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_clarify-0.1.1 lib/mongo_clarify/investigate_with_pattern_matching.rb