Skip to content

Commit

Permalink
Added sqlstatcpuio
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbydurrett committed Aug 8, 2017
1 parent b14ca5e commit f6773a7
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ sessioncounts.py - Plot the number of connected sessions.
segstat.py - Segment usage statistics for one segment

ashonewait.py - Show the number of sessions active on one particular wait.

sqlstatcpuio.py - Plots total elapsed, cpu, and io seconds for a single sql_id.


Command line help:

Expand Down
69 changes: 69 additions & 0 deletions sqlstatcpuio.py
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()

0 comments on commit f6773a7

Please sign in to comment.