mysql_dump_slow 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mysql_dump_slow/counter.rb +4 -3
- data/lib/mysql_dump_slow/sql.rb +15 -0
- data/lib/mysql_dump_slow/summary.rb +4 -5
- data/lib/mysql_dump_slow/version.rb +1 -1
- data/lib/mysql_dump_slow.rb +1 -1
- data/mysql_dump_slow.gemspec +0 -2
- metadata +3 -17
- data/lib/mysql_dump_slow/masked_sql_parser.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e44c57040c2a9cc336b30e839fd0c5c69fe37d4
|
4
|
+
data.tar.gz: 200d9f11707ca8670faa3a92daddae7cd88ccca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e44086d502cd8d0e12ba9bf264bdf22d31b9a937eb99d48e0e04515587abceaf84c0c983a770b1e73bb1adc4cbaf5188af2c41c9dacefbe5576475aceea1fffd
|
7
|
+
data.tar.gz: f97b94b75c2c415e90ccdcdf45c775ad446c6afbb00ca46bc193c50ffe292bc5ff1ee875381753ff1ce36c4e3826648537db5a527cd419bc85acb5cc8201a691
|
@@ -2,6 +2,8 @@ module MysqlDumpSlow
|
|
2
2
|
class Counter
|
3
3
|
attr_reader :abstract_query, :total_count, :total_query_time, :total_lock_time, :total_rows_sent, :user_hosts
|
4
4
|
|
5
|
+
TIME_BASE_SEC = Time.local(2000, 1, 1).to_i
|
6
|
+
|
5
7
|
def initialize(abstract_query)
|
6
8
|
@abstract_query = abstract_query
|
7
9
|
end
|
@@ -46,12 +48,12 @@ Count: #{total_count} Time=#{average_query_time/1000}s (#{total_query_time/1000
|
|
46
48
|
|
47
49
|
def count_up_query_time(query_time)
|
48
50
|
@total_query_time ||= 0
|
49
|
-
@total_query_time += time_to_ms(query_time)
|
51
|
+
@total_query_time += time_to_ms(query_time - TIME_BASE_SEC)
|
50
52
|
end
|
51
53
|
|
52
54
|
def count_up_lock_time(lock_time)
|
53
55
|
@total_lock_time ||= 0
|
54
|
-
@total_lock_time += time_to_ms(lock_time)
|
56
|
+
@total_lock_time += time_to_ms(lock_time - TIME_BASE_SEC)
|
55
57
|
end
|
56
58
|
|
57
59
|
def count_up_rows_sent(rows_sent)
|
@@ -69,4 +71,3 @@ Count: #{total_count} Time=#{average_query_time/1000}s (#{total_query_time/1000
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
72
|
-
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MysqlDumpSlow
|
2
|
+
class Sql
|
3
|
+
def self.mask(sql)
|
4
|
+
sql.gsub(/\b\d+\b/, 'N')
|
5
|
+
.gsub(/\b0x[0-9A-Fa-f]+\b/, 'N')
|
6
|
+
.gsub(/''/, "'S'")
|
7
|
+
.gsub(/""/, '"S"')
|
8
|
+
.gsub(/(\\')/, '')
|
9
|
+
.gsub(/(\\")/, '')
|
10
|
+
.gsub(/'[^']+'/, "'S'")
|
11
|
+
.gsub(/"[^"]+"/, '"S"')
|
12
|
+
.gsub(/"[^"]+"/, '"S"')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -13,16 +13,15 @@ module MysqlDumpSlow
|
|
13
13
|
end.reverse
|
14
14
|
end
|
15
15
|
|
16
|
-
def each
|
17
|
-
summary.each
|
16
|
+
def each(&block)
|
17
|
+
summary.each(&block)
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def summarize
|
23
|
-
|
24
|
-
|
25
|
-
sql = parser.scan_str(log.sql_text).to_sql
|
23
|
+
@logs.find_each do |log|
|
24
|
+
sql = Sql.mask(log.sql_text)
|
26
25
|
counter = summary.find{|s| s.abstract_query == sql }
|
27
26
|
counter ||= ( summary << Counter.new(sql) ).last
|
28
27
|
counter.count_up(log)
|
data/lib/mysql_dump_slow.rb
CHANGED
data/mysql_dump_slow.gemspec
CHANGED
@@ -19,8 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "sql-parser", "~> 0.0.2"
|
23
|
-
|
24
22
|
spec.add_development_dependency "bundler", "~> 1.10"
|
25
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
24
|
spec.add_development_dependency "minitest"
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_dump_slow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- monochromegane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: sql-parser
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.2
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +84,7 @@ files:
|
|
98
84
|
- bin/setup
|
99
85
|
- lib/mysql_dump_slow.rb
|
100
86
|
- lib/mysql_dump_slow/counter.rb
|
101
|
-
- lib/mysql_dump_slow/
|
87
|
+
- lib/mysql_dump_slow/sql.rb
|
102
88
|
- lib/mysql_dump_slow/summary.rb
|
103
89
|
- lib/mysql_dump_slow/version.rb
|
104
90
|
- mysql_dump_slow.gemspec
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "sql-parser"
|
2
|
-
module SQLParser
|
3
|
-
class SQLVisitor
|
4
|
-
def visit_DateTime(o); "'S'"; end
|
5
|
-
def visit_Date(o); "'S'"; end
|
6
|
-
def visit_String(o); "'S'"; end
|
7
|
-
def visit_ApproximateFloat(o); 'N'; end
|
8
|
-
def visit_Float(o); 'N'; end
|
9
|
-
def visit_Integer(o); 'N'; end
|
10
|
-
end
|
11
|
-
end
|