Class: RailsPulse::Analysis::IndexRecommendationEngine

Inherits:
BaseAnalyzer
  • Object
show all
Defined in:
app/services/rails_pulse/analysis/index_recommendation_engine.rb

Instance Attribute Summary

Attributes inherited from BaseAnalyzer

#operations, #query

Instance Method Summary collapse

Methods inherited from BaseAnalyzer

#initialize

Constructor Details

This class inherits a constructor from RailsPulse::Analysis::BaseAnalyzer

Instance Method Details

#analyzeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/rails_pulse/analysis/index_recommendation_engine.rb', line 6

def analyze
  return [] unless sql.present?

  recommendations = []

  # Analyze WHERE clause for single column indexes
  recommendations.concat(analyze_where_clause_indexes)

  # Analyze JOIN conditions for indexes
  recommendations.concat(analyze_join_indexes)

  # Analyze ORDER BY clauses for indexes
  recommendations.concat(analyze_order_by_indexes)

  # Analyze composite index opportunities
  recommendations.concat(analyze_composite_index_opportunities)

  # Check for covering index opportunities
  recommendations.concat(analyze_covering_index_opportunities)

  # Prioritize recommendations based on query frequency and complexity
  prioritize_recommendations(recommendations)
end