Class: PgReports::ExplainAnalyzer
- Inherits:
-
Object
- Object
- PgReports::ExplainAnalyzer
- Defined in:
- lib/pg_reports/explain_analyzer.rb
Overview
Analyzes EXPLAIN ANALYZE output and extracts insights
Constant Summary collapse
- NODE_TYPES =
Node types and their characteristics
{ "Seq Scan" => {color: "warning", description: "Full table scan - potentially slow for large tables"}, "Index Scan" => {color: "good", description: "Using an index efficiently"}, "Index Only Scan" => {color: "good", description: "Most efficient - reading only from index"}, "Bitmap Index Scan" => {color: "ok", description: "First step of bitmap scan"}, "Bitmap Heap Scan" => {color: "ok", description: "Using multiple indexes combined"}, "Nested Loop" => {color: "neutral", description: "Joining tables in a loop"}, "Hash Join" => {color: "good", description: "Efficient join using hash table"}, "Merge Join" => {color: "good", description: "Efficient join on sorted data"}, "Sort" => {color: "warning", description: "Sorting data in memory or disk"}, "HashAggregate" => {color: "ok", description: "Grouping using hash table"}, "GroupAggregate" => {color: "ok", description: "Grouping on sorted data"}, "Aggregate" => {color: "ok", description: "Computing aggregate functions"}, "Limit" => {color: "good", description: "Limiting result set"}, "Subquery Scan" => {color: "neutral", description: "Scanning a subquery result"}, "CTE Scan" => {color: "neutral", description: "Scanning a Common Table Expression"}, "Materialize" => {color: "warning", description: "Caching intermediate results"}, "Gather" => {color: "ok", description: "Parallel query coordination"}, "Gather Merge" => {color: "ok", description: "Parallel query with merge"} }.freeze
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#problems ⇒ Object
readonly
Returns the value of attribute problems.
-
#raw_output ⇒ Object
readonly
Returns the value of attribute raw_output.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
-
#initialize(explain_output) ⇒ ExplainAnalyzer
constructor
A new instance of ExplainAnalyzer.
- #to_h ⇒ Object
Constructor Details
#initialize(explain_output) ⇒ ExplainAnalyzer
Returns a new instance of ExplainAnalyzer.
30 31 32 33 34 35 36 |
# File 'lib/pg_reports/explain_analyzer.rb', line 30 def initialize(explain_output) @raw_output = explain_output @lines = explain_output.split("\n") @problems = [] @summary = {} analyze end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
28 29 30 |
# File 'lib/pg_reports/explain_analyzer.rb', line 28 def lines @lines end |
#problems ⇒ Object (readonly)
Returns the value of attribute problems.
28 29 30 |
# File 'lib/pg_reports/explain_analyzer.rb', line 28 def problems @problems end |
#raw_output ⇒ Object (readonly)
Returns the value of attribute raw_output.
28 29 30 |
# File 'lib/pg_reports/explain_analyzer.rb', line 28 def raw_output @raw_output end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
28 29 30 |
# File 'lib/pg_reports/explain_analyzer.rb', line 28 def summary @summary end |
Instance Method Details
#to_h ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/pg_reports/explain_analyzer.rb', line 38 def to_h { raw_output: @raw_output, annotated_lines: annotate_lines, problems: @problems, summary: @summary, stats: extract_stats } end |