Class: Dexter::Query
- Inherits:
-
Object
- Object
- Dexter::Query
- Defined in:
- lib/dexter/query.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#candidate_columns ⇒ Object
Returns the value of attribute candidate_columns.
-
#candidate_tables ⇒ Object
Returns the value of attribute candidate_tables.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#index_mapping ⇒ Object
Returns the value of attribute index_mapping.
-
#indexes ⇒ Object
Returns the value of attribute indexes.
-
#missing_tables ⇒ Object
Returns the value of attribute missing_tables.
-
#new_cost ⇒ Object
Returns the value of attribute new_cost.
-
#pass1_indexes ⇒ Object
Returns the value of attribute pass1_indexes.
-
#pass2_indexes ⇒ Object
Returns the value of attribute pass2_indexes.
-
#pass3_indexes ⇒ Object
Returns the value of attribute pass3_indexes.
-
#plans ⇒ Object
readonly
Returns the value of attribute plans.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
-
#suggest_index ⇒ Object
Returns the value of attribute suggest_index.
-
#tables ⇒ Object
Returns the value of attribute tables.
-
#tables_from_views ⇒ Object
Returns the value of attribute tables_from_views.
-
#total_time ⇒ Object
readonly
Returns the value of attribute total_time.
Instance Method Summary collapse
- #costs ⇒ Object
- #fully_analyzed? ⇒ Boolean
- #initial_cost ⇒ Object
-
#initialize(statement, fingerprint = nil, total_time: nil, calls: nil) ⇒ Query
constructor
A new instance of Query.
- #parser_result ⇒ Object
- #tree ⇒ Object
Constructor Details
#initialize(statement, fingerprint = nil, total_time: nil, calls: nil) ⇒ Query
Returns a new instance of Query.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dexter/query.rb', line 6 def initialize(statement, fingerprint = nil, total_time: nil, calls: nil) @statement = statement @fingerprint = fingerprint @total_time = total_time @calls = calls @plans = [] @tables_from_views = [] @candidate_tables = [] @columns = [] @candidate_columns = [] end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
3 4 5 |
# File 'lib/dexter/query.rb', line 3 def calls @calls end |
#candidate_columns ⇒ Object
Returns the value of attribute candidate_columns.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def candidate_columns @candidate_columns end |
#candidate_tables ⇒ Object
Returns the value of attribute candidate_tables.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def candidate_tables @candidate_tables end |
#columns ⇒ Object
Returns the value of attribute columns.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def columns @columns end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
3 4 5 |
# File 'lib/dexter/query.rb', line 3 def fingerprint @fingerprint end |
#index_mapping ⇒ Object
Returns the value of attribute index_mapping.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def index_mapping @index_mapping end |
#indexes ⇒ Object
Returns the value of attribute indexes.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def indexes @indexes end |
#missing_tables ⇒ Object
Returns the value of attribute missing_tables.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def missing_tables @missing_tables end |
#new_cost ⇒ Object
Returns the value of attribute new_cost.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def new_cost @new_cost end |
#pass1_indexes ⇒ Object
Returns the value of attribute pass1_indexes.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def pass1_indexes @pass1_indexes end |
#pass2_indexes ⇒ Object
Returns the value of attribute pass2_indexes.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def pass2_indexes @pass2_indexes end |
#pass3_indexes ⇒ Object
Returns the value of attribute pass3_indexes.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def pass3_indexes @pass3_indexes end |
#plans ⇒ Object (readonly)
Returns the value of attribute plans.
3 4 5 |
# File 'lib/dexter/query.rb', line 3 def plans @plans end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
3 4 5 |
# File 'lib/dexter/query.rb', line 3 def statement @statement end |
#suggest_index ⇒ Object
Returns the value of attribute suggest_index.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def suggest_index @suggest_index end |
#tables ⇒ Object
Returns the value of attribute tables.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def tables @tables end |
#tables_from_views ⇒ Object
Returns the value of attribute tables_from_views.
4 5 6 |
# File 'lib/dexter/query.rb', line 4 def tables_from_views @tables_from_views end |
#total_time ⇒ Object (readonly)
Returns the value of attribute total_time.
3 4 5 |
# File 'lib/dexter/query.rb', line 3 def total_time @total_time end |
Instance Method Details
#costs ⇒ Object
33 34 35 |
# File 'lib/dexter/query.rb', line 33 def costs plans.map { |plan| plan["Total Cost"] } end |
#fully_analyzed? ⇒ Boolean
29 30 31 |
# File 'lib/dexter/query.rb', line 29 def fully_analyzed? plans.size >= 3 end |
#initial_cost ⇒ Object
37 38 39 |
# File 'lib/dexter/query.rb', line 37 def initial_cost costs[0] end |
#parser_result ⇒ Object
18 19 20 21 22 23 |
# File 'lib/dexter/query.rb', line 18 def parser_result unless defined?(@parser_result) @parser_result = PgQuery.parse(statement) rescue nil end @parser_result end |
#tree ⇒ Object
25 26 27 |
# File 'lib/dexter/query.rb', line 25 def tree parser_result.tree end |