Class: Maatkit::QueryAdvisor

Inherits:
Object
  • Object
show all
Defined in:
lib/maatkit-ruby/mk-query-advisor.rb

Overview

Analyze queries and advise on possible problems.

Maatkit::QueryAdvisor.new( array, str, array)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQueryAdvisor

Returns a new QueryAdvisor Object



48
49
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 48

def initialize()
end

Instance Attribute Details

#ask_passObject

FALSE



15
16
17
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 15

def ask_pass
  @ask_pass
end

#charsetObject

(No # value)



16
17
18
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 16

def charset
  @charset
end

#configObject

/etc/maatkit/maatkit.conf,/etc/maatkit/mk_query_advisor.conf,/home/joel/.maatkit.conf,/home/joel/.mk_query_advisor.conf



17
18
19
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 17

def config
  @config
end

#continue_on_errorObject

TRUE



18
19
20
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 18

def continue_on_error
  @continue_on_error
end

#daemonizeObject

FALSE



19
20
21
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 19

def daemonize
  @daemonize
end

#defaults_fileObject

(No # value)



20
21
22
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 20

def defaults_file
  @defaults_file
end

#helpObject

TRUE



21
22
23
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 21

def help
  @help
end

#hostObject

(No # value)



22
23
24
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 22

def host
  @host
end

#ignore_rulesObject

(No # value)



23
24
25
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 23

def ignore_rules
  @ignore_rules
end

#passwordObject

(No # value)



24
25
26
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 24

def password
  @password
end

#path_to_mk_query_advisorObject

Sets the executable path, otherwise the environment path will be used.



43
44
45
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 43

def path_to_mk_query_advisor
  @path_to_mk_query_advisor
end

#pidObject

(No # value)



25
26
27
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 25

def pid
  @pid
end

#portObject

(No # value)



26
27
28
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 26

def port
  @port
end

FALSE



27
28
29
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 27

def print_all
  @print_all
end

#queryObject

(No # value)



28
29
30
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 28

def query
  @query
end

#report_formatObject

compact



29
30
31
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 29

def report_format
  @report_format
end

#reviewObject

(No # value)



30
31
32
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 30

def review
  @review
end

#sampleObject

1



31
32
33
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 31

def sample
  @sample
end

#set_varsObject

wait_timeout=10000



32
33
34
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 32

def set_vars
  @set_vars
end

#socketObject

(No # value)



33
34
35
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 33

def socket
  @socket
end

#typeObject

slowlog



34
35
36
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 34

def type
  @type
end

#userObject

(No # value)



35
36
37
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 35

def user
  @user
end

#verboseObject

1



36
37
38
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 36

def verbose
  @verbose
end

#versionObject

FALSE



37
38
39
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 37

def version
  @version
end

#whereObject

(No # value)



38
39
40
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 38

def where
  @where
end

Instance Method Details

#start(options = nil) ⇒ Object

Execute the command



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/maatkit-ruby/mk-query-advisor.rb', line 54

def start(options = nil)
  tmp = Tempfile.new('tmp')
  command = option_string() + options.to_s + " 2> " + tmp.path
  success = system(command)
  if success
    begin
      while (line = tmp.readline)
        line.chomp
        selected_string = line
      end
    rescue EOFError
      tmp.close
    end
    return selected_string
  else
    tmp.close!
    return success
  end
end