Search notes:

AWR Query: Count of Sessions (and display it in an Excel chart)

Execute this query in SQL Developer
select
   cast(any_value(sample_time) as date) - date '1899-12-30' sample_time_xls, -- See converting an Oracle DATE to an Excel serial number
   count(*) cnt,
   count(*) - count(event) cnt_on_cpu
from
   dba_hist_active_sess_history
where
   dbid = (select dbid from v$database)
group by
   sample_id,
   dbid
having
   any_value(sample_time) between trunc(sysdate-4) and trunc(sysdate-3)
order by
   any_value(sample_time)
Open an new Excel workbook and open the immediate window, then copy paste the following code.
Then copy the result set of the previous query into the clipboard.
Then execute the following commands.
range("a1:c1").value = array("Time", "Sessions", "on CPU")
range("a2").select

'
'  NOW PASTE (select worksheet, ctrl-v) the result set of the query
'

columns("A:A").numberFormat = "hh:mm"
set datasrc = range("a1").CurrentRegion

set sh = activeSheet.shapes.addChart2(240, xlXYScatterLinesNoMarkers)
set ch=sh.chart
ch.setSourceData  source := datasrc

ch.chartTitle.text = "Count of sessions"

sh.left   =   10
sh.width  = activeWorkbook.windows(1).usableWidth  - 20
sh.top    =   20
sh.height = activeWorkbook.windows(1).usableHeight - 40

ch.axes(xlCategory).minimumScale = cLng(int(now() - 4))
ch.axes(xlCategory).maximumScale = cLng(int(now() - 3))
ch.axes(xlCategory).majorUnit    = 1/24

set ser_1 = ch.fullSeriesCollection(1)
set ser_2 = ch.fullSeriesCollection(2)

ser_1.format.line.weight = 0.5
ser_2.format.line.weight = 0.5

ser_1.format.line.foreColor.rgb = rgb( 30, 60, 255)
ser_2.format.line.foreColor.rgb = rgb(255, 30,  60)

See also

Automatic Workload Repository

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759428692, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/Automatic-Workload-Repository/queries/count-of-sessions(93): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78