際際滷
Submit Search
もにかじ2 lt @studio3104
?
2 likes
?
936 views
S
Satoshi Suzuki
Follow
1 of 16
Download now
Download to read offline
More Related Content
もにかじ2 lt @studio3104
1.
Lightning Talk at
Monitoring Casual #2 Oの茶氏ですが、 ちょっとMySQLのをしますね @studio3104
2.
@studio3104 (Satoshi SUZUKI) --
Perls磯定くらい -- WEBI順2定朕 -- 曇、弟、連徨います -- ソシャゲ、巷塀サイト、パチ(スロ)ンコ -- こんなのやってます ★★★★★★★ -- Perlと伉嶄するらしいです 徭失B初
3.
スロ`クエリ
4.
とりあえず
5.
EXPLAIN
9.
riywoさん マジriywoさん
10.
Wも恬ってみた 仝out-exec-mysql-
壊鉛看敬援顎艶姻霞々
11.
MySQL
slow_log 1 #!/usr/bin/env perl$ 27 $ tail 2$ 28 unless ( defined $slowlog->{sql} ) {$ 3 use strict;$ 29 print $mp->pack($slowlog);$ 4 use warnings;$ 30 next;$ 5 use Data::Dumper;$ 31 }$ EXPLAIN 6 use DBIx::Handler;$ 7 use JSON::XS;$ 32 $ 33 my $select_statement;$ 8 use Data::MessagePack;$ 34 if ( $slowlog->{sql} =~ /(select[^;]+)/i ) {$ 9$ 35 $select_statement = $1;$ 10 $| = 1;$ 36 }$ 11 $ 37 $ 12 my $mp = Data::MessagePack->new();$ 38 if ( $slowlog->{sql} =~ /^use ([^;]+)/i ) {$ 13 $ 39 $db = '`' . $1 . '`';$ 14 my $db_user = "root";$ 40 }$ 15 my $db_passwd = "";$ 41 $ 16 my $db_opt = { RaiseError => 0, PrintError => 1 };$ 42 if ( defined $db && defined $select_statement ) {$ 17 my $handler = DBIx::Handler->new( "DBI:mysql: 43 $handler->dbh->do("use $db");$ database=information_schema:1 27.0.0.1", $db_user, 44 my $explains = eval { $handler->dbh- $db_passwd, $db_opt );$ >selectall_arrayref( "EXPLAIN $selec t_statement", +{ 18 $ Slice => {} } ); };$ 19 my $db;$ 45 if ( ref $explains eq 'ARRAY' ) {$ 20 my $long_query_time = $handler->dbh- 46 $slowlog->{explain} = $explains;$ >selectrow_array($ 47 $slowlog->{database} = $db;$ 21 "SELECT VARIABLE_VALUE FROM 48 }$ GLOBAL_VARIABLES WHERE VARIABLE_NAME = 49 }$ 'LONG_Q UERY_TIME'");$ 50 $ 22 $handler->dbh->do("SELECT SLEEP 51 print $mp->pack($slowlog);$ ($long_query_time)");$ 52 }$ 23 $ 24 while ( my $json = <STDIN> ) {$ 25 my $slowlog = eval { decode_json($json); };$ 26 next if ($@);$ store MongoDB
12.
DEMO
13.
Openess is our driver
for excellence
14.
巷_したよ https://github.com/studio3104/out-exec-mysql-slowquery
15.
ス`パ`傚札織ぅ
16.
Lightning Talk at
Monitoring Casual #2 Oの茶氏ですが、 ちょっとMySQLのをしますね ご賠ありがとうございました @studio3104
Download