Class: MongoClarify::Investigate

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_clarify/investigate_with_pattern_matching.rb,
lib/mongo_clarify/investigate_without_pattern_matching.rb

Instance Method Summary collapse

Constructor Details

#initialize(explain) ⇒ Investigate

Returns a new instance of Investigate.



5
6
7
# File 'lib/mongo_clarify/investigate_with_pattern_matching.rb', line 5

def initialize(explain)
  @explain = explain
end

Instance Method Details

#execution_statsObject



20
21
22
23
24
25
26
27
# File 'lib/mongo_clarify/investigate_with_pattern_matching.rb', line 20

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

#operation_methodObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/mongo_clarify/investigate_with_pattern_matching.rb', line 9

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