Class: Fiveruns::Tuneup::Step::SQL::Explain

Inherits:
Object
  • Object
show all
Defined in:
lib/fiveruns/tuneup/step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sql, connection) ⇒ Explain

Returns a new instance of Explain.



167
168
169
170
171
172
173
174
175
176
# File 'lib/fiveruns/tuneup/step.rb', line 167

def initialize(sql, connection)
  result = connection.execute("explain #{sql}")
  @fields = fetch_fields_from(result)
  @rows = fetch_rows_from(result)
  result.free
  add_schemas(connection)
  @valid = true
rescue Exception
  @valid = false
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



165
166
167
# File 'lib/fiveruns/tuneup/step.rb', line 165

def fields
  @fields
end

#rowsObject (readonly)

Returns the value of attribute rows.



165
166
167
# File 'lib/fiveruns/tuneup/step.rb', line 165

def rows
  @rows
end

Instance Method Details

#table_offsetObject



182
183
184
# File 'lib/fiveruns/tuneup/step.rb', line 182

def table_offset
  @table_offset ||= @fields.index('table')
end

#valid?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/fiveruns/tuneup/step.rb', line 178

def valid?
  @valid
end