Class: SqlQueryAnalyzer::SequentialScanAdvisor
- Inherits:
-
Object
- Object
- SqlQueryAnalyzer::SequentialScanAdvisor
- Defined in:
- lib/sql_query_analyzer/sequential_scan_advisor.rb
Instance Attribute Summary collapse
-
#query_plan ⇒ Object
readonly
Returns the value of attribute query_plan.
Instance Method Summary collapse
- #enhanced_message ⇒ Object
-
#initialize(query_plan) ⇒ SequentialScanAdvisor
constructor
A new instance of SequentialScanAdvisor.
Constructor Details
#initialize(query_plan) ⇒ SequentialScanAdvisor
Returns a new instance of SequentialScanAdvisor.
5 6 7 |
# File 'lib/sql_query_analyzer/sequential_scan_advisor.rb', line 5 def initialize(query_plan) @query_plan = query_plan end |
Instance Attribute Details
#query_plan ⇒ Object (readonly)
Returns the value of attribute query_plan.
3 4 5 |
# File 'lib/sql_query_analyzer/sequential_scan_advisor.rb', line 3 def query_plan @query_plan end |
Instance Method Details
#enhanced_message ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sql_query_analyzer/sequential_scan_advisor.rb', line 9 def table_name, column_names = extract_table_and_columns return nil unless sequential_scan_detected? if column_names.empty? return "👉 [CRITICAL] ⚡ 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 = [] << "👉 [CRITICAL] ⚡ Sequential Scan detected on '#{table_name}', " \ "and filter involves columns: #{column_names.join(', ')}." if missing_composite_index?(table_name, column_names) << "💡 Consider adding a composite index on: #{column_names.join(', ')}" end .join("\n") end |