Class: Benedictus::Heuristics::NestedLoopBlowup
- Defined in:
- lib/benedictus/heuristics/nested_loop_blowup.rb
Constant Summary collapse
- DEFAULT_THRESHOLD =
10_000
Class Method Summary collapse
Instance Method Summary collapse
- #apply(node) ⇒ Object
-
#initialize(threshold: DEFAULT_THRESHOLD) ⇒ NestedLoopBlowup
constructor
A new instance of NestedLoopBlowup.
Methods inherited from Base
Constructor Details
#initialize(threshold: DEFAULT_THRESHOLD) ⇒ NestedLoopBlowup
Returns a new instance of NestedLoopBlowup.
12 13 14 15 |
# File 'lib/benedictus/heuristics/nested_loop_blowup.rb', line 12 def initialize(threshold: DEFAULT_THRESHOLD) super() @threshold = threshold end |
Class Method Details
.config_key ⇒ Object
8 9 10 |
# File 'lib/benedictus/heuristics/nested_loop_blowup.rb', line 8 def self.config_key :nested_loop_threshold end |
Instance Method Details
#apply(node) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/benedictus/heuristics/nested_loop_blowup.rb', line 17 def apply(node) return [] unless node.node_type == "Nested Loop" inner = node.children.find { |c| c.parent_relationship == "Inner" } || node.children.last return [] unless inner&.actual_loops && inner.actual_loops > @threshold [ warning( severity: :warning, code: :nested_loop_blowup, message: "Nested Loop drove #{inner.actual_loops} iterations on the inner side.", suggestion: "Consider a Hash Join or Merge Join — try increasing `work_mem` or rewriting the join." ) ] end |