class NoSE::Plans::QueryPlan
A single plan for a query
Attributes
cost_model[RW]
query[RW]
steps[R]
Public Class Methods
new(query, cost_model)
click to toggle source
# File lib/nose/plans/query_planner.rb, line 167 def initialize(query, cost_model) @steps = [] @query = query @cost_model = cost_model end
Public Instance Methods
<=>(other)
click to toggle source
Two plans are compared by their execution cost @return [Boolean]
# File lib/nose/plans/query_planner.rb, line 206 def <=>(other) cost <=> other.cost end
cost()
click to toggle source
The estimated cost of executing the query using this plan @return [Numeric]
# File lib/nose/plans/query_planner.rb, line 212 def cost costs = @steps.map(&:cost) costs.inject(0, &:+) unless costs.any?(&:nil?) end
group()
click to toggle source
Groups for plans are stored in the query @return [String]
# File lib/nose/plans/query_planner.rb, line 183 def group @query.group end
indexes()
click to toggle source
Get the indexes used by this query plan @return [Array<Index>]
# File lib/nose/plans/query_planner.rb, line 219 def indexes @steps.select { |step| step.is_a? IndexLookupPlanStep }.map(&:index) end
name()
click to toggle source
Name plans after the associated query @return [String]
# File lib/nose/plans/query_planner.rb, line 189 def name @query.text end
params()
click to toggle source
Parameters to this execution plan
# File lib/nose/plans/query_planner.rb, line 200 def params @query.conditions end
select_fields()
click to toggle source
Fields
selected by this plan @return [Array<Fields::Field>]
# File lib/nose/plans/query_planner.rb, line 195 def select_fields @query.select end
weight()
click to toggle source
The weight of this query for a given workload @return [Integer]
# File lib/nose/plans/query_planner.rb, line 175 def weight return 1 if @workload.nil? @workload.statement_weights[@query] end