Class: PgCanary::Rules::UnindexedWhere

Inherits:
Base
  • Object
show all
Defined in:
lib/pg_canary/rules/definitions/unindexed_where.rb

Overview

equality/range predicates on columns with no index whose leading column could serve them. Depends on production table size — a 30-row lookup table is fine without indexes — hence disabled by default.

Instance Method Summary collapse

Methods inherited from Base

all, check, default_enabled, enabled?, #initialize, option, options, rule_name

Constructor Details

This class inherits a constructor from PgCanary::Rules::Base

Instance Method Details

#checkObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pg_canary/rules/definitions/unindexed_where.rb', line 14

def check
  each_scope.with_object([]) do |scope, detections|
    next unless scope.where_clause

    predicate_columns(scope).each do |table, columns|
      next unless applicable_table?(table)
      next if served_by_index?(table, columns)

      detections << build(table, columns)
    end
  end
end