Class: SqlQueryAnalyzer::SequentialScanAdvisor
- Inherits:
-
Object
- Object
- SqlQueryAnalyzer::SequentialScanAdvisor
- Defined in:
- lib/sql_query_analyzer/sequential_scan_advisor.rb
Instance Method Summary collapse
- #enhanced_message ⇒ Object
-
#initialize(line_text) ⇒ SequentialScanAdvisor
constructor
A new instance of SequentialScanAdvisor.
Constructor Details
#initialize(line_text) ⇒ SequentialScanAdvisor
Returns a new instance of SequentialScanAdvisor.
3 4 5 |
# File 'lib/sql_query_analyzer/sequential_scan_advisor.rb', line 3 def initialize(line_text) @line_text = line_text end |
Instance Method Details
#enhanced_message ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sql_query_analyzer/sequential_scan_advisor.rb', line 7 def table_name, column_names = extract_table_and_columns return nil unless table_name if column_names.empty? return "⚡ Sequential Scan detected on '#{table_name}', but no filter condition found. Likely a full table read (e.g., SELECT *), or small table size makes index use unnecessary." end missing_indexes = column_names.select do |column| !index_exists?(table_name, column) end if missing_indexes.any? "⚡ Sequential Scan detected on '#{table_name}'. Consider adding indexes on: #{missing_indexes.join(', ')}." else "⚡ Sequential Scan detected on '#{table_name}', but indexes seem to exist. Might be due to low table size or outdated stats." end end |