Class: UnnestedInFilters::Rewriter::IndexCoverage
- Inherits:
 - 
      Object
      
        
- Object
 - UnnestedInFilters::Rewriter::IndexCoverage
 
 
- Defined in:
 - lib/unnested_in_filters/rewriter.rb
 
Overview
A naive query planner implementation. Checks if a database-level index can be utilized by given filtering and ordering predicates.
Supported index conditions:
- All columns queried are present in the index or partial predicate
- Unqueried index columns are at the end of the index
- Partial indices if the partial index predicate contains only one column.
- Only the `=` operator present in partial index predicate.
Examples:
Queried | Index | Supported? (col_1, col_2) | (col_1, col_2) | Y (col_1) | (col_1, col_2) | Y (col_2) | (col_1, col_2) | N (col_1, col_3) | (col_1, col_2, col_3) | N (col_1, col_2) | (col_1) where col_2 = “1” | Y (col_1, col_2) | (col_1) where col_2 <= 1 | N (col_1, col_2) | (col_1) where col_2 IS NULL | N (col_1, col_2) | (col_1) where col_2 = “1” AND COL_1 = “2” | N
Constant Summary collapse
- PARTIAL_INDEX_REGEX =
 /(?<!\s)(?>\(*(?<column_name>\b\w+)\s*=\s*(?<column_value>\w+)\)*)(?!\s)/
Instance Method Summary collapse
- #covers? ⇒ Boolean
 - 
  
    
      #initialize(index, where_hash, order_attributes)  ⇒ IndexCoverage 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of IndexCoverage.
 
Constructor Details
#initialize(index, where_hash, order_attributes) ⇒ IndexCoverage
Returns a new instance of IndexCoverage.
      101 102 103 104 105  | 
    
      # File 'lib/unnested_in_filters/rewriter.rb', line 101 def initialize(index, where_hash, order_attributes) @index = index @where_hash = where_hash @order_attributes = order_attributes end  | 
  
Instance Method Details
#covers? ⇒ Boolean
      107 108 109 110 111  | 
    
      # File 'lib/unnested_in_filters/rewriter.rb', line 107 def covers? filter_attributes_covered? && unused_columns_at_end_of_index? && can_be_used_for_sorting? end  |