Class: MongoClarify::Investigate
- Inherits:
-
Object
- Object
- MongoClarify::Investigate
- Defined in:
- lib/mongo_clarify/investigate.rb
Instance Method Summary collapse
- #execution_stats ⇒ Object
-
#initialize(explain) ⇒ Investigate
constructor
A new instance of Investigate.
- #operation_method ⇒ Object
Constructor Details
#initialize(explain) ⇒ Investigate
Returns a new instance of Investigate.
9 10 11 |
# File 'lib/mongo_clarify/investigate.rb', line 9 def initialize(explain) @explain = explain end |
Instance Method Details
#execution_stats ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mongo_clarify/investigate.rb', line 26 def execution_stats match(@explain) do with(Hash.(executionStats: Hash.(nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs))) do { n_returned: n, execution_time_millis: msec, total_keys_examined: keys, total_docs_examined: docs } end end rescue PatternMatch::NoMatchingPatternError nil end |
#operation_method ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mongo_clarify/investigate.rb', line 13 def operation_method match(@explain) do with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'COLLSCAN')))) do 'Collection Scan' end with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'FETCH', inputStage: Hash.(stage: 'IXSCAN', indexName: index_name))))) do "Index Scan (Index Name: #{index_name})" end end rescue PatternMatch::NoMatchingPatternError nil end |