forked from bobbydurrett/PythonDBAGraphs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallsql.py
More file actions
62 lines (44 loc) · 1.63 KB
/
allsql.py
File metadata and controls
62 lines (44 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
PythonDBAGraphs: Graphs to help with Oracle Database Tuning
Copyright (C) 2016 Robert Taft Durrett (Bobby Durrett)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Contact:
bobby@bobbydurrettdba.com
allsql.py
Execution statistics for all SQL statements
"""
import myplot
import util
def allsql():
q_string = """select
sn.END_INTERVAL_TIME,
sum(ss.executions_delta) TOTAL_EXECUTIONS,
sum(ELAPSED_TIME_DELTA)/(sum(executions_delta)*1000) ELAPSED_AVG_MS
from DBA_HIST_SQLSTAT ss,DBA_HIST_SNAPSHOT sn
where
ss.snap_id=sn.snap_id
and executions_delta > 0
and ss.INSTANCE_NUMBER=sn.INSTANCE_NUMBER
group by sn.END_INTERVAL_TIME
order by sn.END_INTERVAL_TIME"""
return q_string
database,dbconnection = util.script_startup('Run statistics for all sql statements')
# Build and run query
q = allsql();
r = dbconnection.run_return_flipped_results(q)
# plot query
myplot.title = "All SQL statements on "+database+" database"
myplot.ylabel1 = "Number of executions"
myplot.ylabel2 = "Averaged Elapsed Milliseconds"
myplot.xdatetimes = r[0]
myplot.ylists = r[1:]
myplot.line_2subplots()