Class: Benedictus::Heuristics::SeqScanOnLargeTable
- Defined in:
- lib/benedictus/heuristics/seq_scan_on_large_table.rb
Constant Summary collapse
- DEFAULT_THRESHOLD =
10_000
Class Method Summary collapse
Instance Method Summary collapse
- #apply(node) ⇒ Object
-
#initialize(threshold: DEFAULT_THRESHOLD) ⇒ SeqScanOnLargeTable
constructor
A new instance of SeqScanOnLargeTable.
Methods inherited from Base
Constructor Details
#initialize(threshold: DEFAULT_THRESHOLD) ⇒ SeqScanOnLargeTable
Returns a new instance of SeqScanOnLargeTable.
12 13 14 15 |
# File 'lib/benedictus/heuristics/seq_scan_on_large_table.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/seq_scan_on_large_table.rb', line 8 def self.config_key :seq_scan_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/seq_scan_on_large_table.rb', line 17 def apply(node) return [] unless node.node_type == "Seq Scan" return [] unless node.plan_rows && node.plan_rows > @threshold relation = node.relation_name || "this table" rows = node.plan_rows [ warning( severity: :critical, code: :seq_scan_on_large_table, message: "Seq Scan on a table with ~#{rows.to_i} estimated rows", suggestion: "Consider adding an index that matches the filter on `#{relation}`." ) ] end |