-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b14ca5e
commit f6773a7
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
""" | ||
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: | ||
[email protected] | ||
sqlstatcpuio.py | ||
Plots total elapsed, cpu, and io seconds for a single sql_id. | ||
""" | ||
|
||
import myplot | ||
import util | ||
|
||
def sqlstatcpuio(sql_id): | ||
q_string = """ | ||
select | ||
sn.END_INTERVAL_TIME, | ||
sum(ELAPSED_TIME_DELTA)/1000000 ELAPSED_SECONDS, | ||
(sum(CPU_TIME_DELTA)+sum(IOWAIT_DELTA))/1000000 CPU_IO_SECONDS, | ||
sum(IOWAIT_DELTA)/1000000 IO_SECONDS | ||
from DBA_HIST_SQLSTAT ss,DBA_HIST_SNAPSHOT sn | ||
where ss.snap_id=sn.snap_id | ||
and ss.INSTANCE_NUMBER=sn.INSTANCE_NUMBER | ||
and ss.SQL_ID='""" | ||
q_string += sql_id | ||
q_string += """' | ||
group by sn.END_INTERVAL_TIME | ||
order by sn.END_INTERVAL_TIME | ||
""" | ||
return q_string | ||
|
||
database,dbconnection = util.script_startup('Elapsed, CPU, and IO for one SQL id') | ||
|
||
sql_id=util.input_with_default('SQL_ID','acrg0q0qtx3gr') | ||
|
||
querytext = sqlstatcpuio(sql_id) | ||
|
||
results = dbconnection.run_return_flipped_results(querytext) | ||
|
||
util.exit_no_results(results) | ||
|
||
# plot query | ||
|
||
myplot.xdatetimes = results[0] | ||
myplot.ylists = results[1:] | ||
|
||
myplot.title = "Sql_id "+sql_id+" on "+database+" database" | ||
myplot.ylabel1 = "Seconds" | ||
|
||
myplot.ylistlabels=["Elapsed","CPU+IO","IO"] | ||
|
||
myplot.line() |