Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0c993b72
Commit
0c993b72
authored
Nov 21, 2000
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysqldumpslow.sh BitKeeper file /my/bk/mysql/scripts/mysqldumpslow.sh
parent
e23a0222
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
scripts/mysqldumpslow.sh
scripts/mysqldumpslow.sh
+76
-0
No files found.
scripts/mysqldumpslow.sh
0 → 100755
View file @
0c993b72
#@perl@
# mysqldumpslow - parse and summarize the MySQL slow query log
use strict
;
use Getopt::Long
;
# t=time, l=lock time, r=rows
# at, al, and ar are the corresponding averages
my %opt
=
(
s
=>
'at'
,
h
=>
'*'
,
)
;
GetOptions
(
\%
opt,
'v+'
,
# verbose
'd+'
,
# debug
's=s'
,
# what to sort by (t, at, l, al, r, ar etc)
'a!'
,
# don't abstract all numbers to N and strings to 'S'
'g=s'
,
# grep: only consider stmts that include this string
'h=s'
,
# hostname of db server (can be wildcard)
)
or die
"Bad option"
;
my %stmt
;
my
$datadir
=
"/var/lib/mysql"
;
# XXX should fetch dynamically
@ARGV
=
<
$datadir
/
$opt
{
h
}
-slow
.log>
;
$/
=
"
\n
#"
;
# read entire statements using paragraph mode
while
(
<
>)
{
print
"[
$_
]
\n
"
if
$opt
{
v
}
;
s/^#// unless %stmt
;
s/
\s
*
Time:
(
\d
+
)
Lock_time:
(
\d
+
)
Rows_sent:
(
\d
+
)
.
*
\n
//
;
my
(
$t
,
$l
,
$r
)
=
(
$1
,
$2
,
$3
)
;
s/^use
\w
+
;
\n
//
;
# not consistently added
s/^SET
timestamp
=
\d
+
;
\n
//
;
s/^[
]
*
\n
//mg
;
# delete blank lines
s/^[
]
*
/ /mg
;
# normalize leading whitespace
s/
\s
*
;
\s
*
(
#\s*)?$//; # remove traing semicolon(+newline-hash)
next
if
$opt
{
g
}
and
!
m/
$opt
{
g
}
/i
;
unless
(
$opt
{
a
})
{
s/
\b\d
+
\b
/N/g
;
s/
\b
0x[0-9A-Fa-f]+
\b
/N/g
;
s/
'.*?'
/
'S'
/g
;
s/
".*?"
/
"S"
/g
;
}
$stmt
{
$_
}
->
{
c
}
+
=
1
;
$stmt
{
$_
}
->
{
t
}
+
=
$t
;
$stmt
{
$_
}
->
{
l
}
+
=
$l
;
$stmt
{
$_
}
->
{
r
}
+
=
$r
;
warn
"[
$_
]"
if
$opt
{
d
}
;
}
foreach
(
keys %stmt
)
{
my
$v
=
$stmt
{
$_
}
||
die
;
my
(
$c
,
$t
,
$l
,
$r
)
=
@
{
$v
}{
qw
(
c t l r
)}
;
$v
->
{
at
}
=
$t
/
$c
;
$v
->
{
al
}
=
$l
/
$c
;
$v
->
{
ar
}
=
$r
/
$c
;
}
my @sorted
=
sort
{
$stmt
{
$a
}
->
{
$opt
{
s
}}
<
=>
$stmt
{
$b
}
->
{
$opt
{
s
}}
}
keys %stmt
;
foreach
(
@sorted
)
{
my
$v
=
$stmt
{
$_
}
||
die
;
my
(
$c
,
$t
,
$at
,
$l
,
$al
,
$r
,
$ar
)
=
@
{
$v
}{
qw
(
c t at l al r ar
)}
;
printf
"Count: %d Time: %.2f (%d) Lock_time: %.2f (%d) Rows_sent: %.1f (%d)
\n
%s
\n\n
"
,
$c
,
$at
,
$t
,
$al
,
$l
,
$ar
,
$r
,
$_
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment