SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Bertrand Drouvot









Oracle DBA since 1999
OCP 9i,10g,11g
Rac certified Expert
Exadata certified implementation specialist
Blogger since 2012
@bertranddrouvot
BasketBall fan








Some examples of R usage with the oracle
database
From a DBA point of view
Retrieve system statistics/wait events with
some AWR queries
Real time Data
Dashboard of the database activity




R installation
R programing
R studio (powerful and productive user
interface for R)




Because R is a powerful tool for statistical
analysis with graphing and plotting packages
built in.
Furthermore, R can connect to Oracle via a
JDBC package which makes importing data
very easy.


http://www.r-project.org/







library(RJDBC)
drv <JDBC("oracle.jdbc.driver.OracleDriver","/ec/pr
od/server/oracle/olrprod1/u000/product/11.
2.0.3/jdbc/lib/ojdbc6.jar")
conn<-dbConnect(drv,conn_string,"sys as
sysasm",sys_pwd)
Data_frame<-dbGetQuery(conn,myquery)
select s.begin_interval_time,sta.stat_name,sta.VALUE,
round(((sta.VALUE)/
(
(extract(day from s.END_INTERVAL_TIME)-extract(day from s.BEGIN_INTERVAL_TIME))*86400 +
(extract(hour from s.END_INTERVAL_TIME)-extract(hour from s.BEGIN_INTERVAL_TIME))*3600 +
(extract(minute from s.END_INTERVAL_TIME)-extract(minute from s.BEGIN_INTERVAL_TIME))*60 +
(extract(second from s.END_INTERVAL_TIME)-extract(second from s.BEGIN_INTERVAL_TIME))
)
),2) VALUE_PER_SEC
from
(
select instance_number,snap_id,stat_name,
value - first_value(value) over (partition by stat_name order by snap_id rows 1 preceding) "VALUE"
from
dba_hist_sysstat
where stat_name like nvl('&stat_name',stat_name)
and instance_number = (select instance_number from v$instance)
) sta, dba_hist_snapshot s
where sta.instance_number=s.instance_number
and sta.snap_id=s.snap_id
and s.BEGIN_INTERVAL_TIME >= trunc(sysdate-&sysdate_nb_day_begin_interval+1)
and s.BEGIN_INTERVAL_TIME <= trunc(sysdate-&sysdate_nb_day_end_interval+1)
order by s.begin_interval_time asc;










# Plot the 4 graphs
par(mfrow =c(4,1))
plot(sqstat[,'DATEEVT'],sqstat[,'VALUE'],type="l",col="blue"
,xaxt="n",main=stat_name,cex.main=2,xlab="",ylab="VAL
UE")
Axis(side=1,at=sqstat$DATEEVT,round(skip),format="%Y/
%m/%d %H:%M")
plot(sqstat[,'DATEEVT'],sqstat[,'VALUE_PER_SEC'],type="l",c
ol="blue",xaxt="n",xlab="",ylab="VALUE_PER_SEC")
Axis(side=1,at=sqstat$DATEEVT,round(skip),format="%Y/
%m/%d %H:%M")
hist(sqstat[,'VALUE'],xlab="VALUE",main=NULL,border="bl
ue")
hist(sqstat[,'VALUE_PER_SEC'],xlab="VALUE_PER_SEC",main
=NULL,border="blue")
select e.WAIT_CLASS,e.event_name,s.begin_interval_time,e.TOTAL_WAITS,e.TIME_WAITED_MS,e.TIME_WAITED_MS /
TOTAL_WAITS "MS_PER_WAIT"
from
(
select instance_number,snap_id,WAIT_CLASS,event_name,
total_waits - first_value(total_waits) over (partition by event_name order by snap_id rows 1 preceding)
"TOTAL_WAITS",
(time_waited_micro - first_value(time_waited_micro) over (partition by event_name order by snap_id rows 1
preceding))/1000 "TIME_WAITED_MS"
from
dba_hist_system_event
where
WAIT_CLASS like nvl('&WAIT_CLASS',WAIT_CLASS)
and event_name like nvl('&event_name',event_name)
and instance_number = (select instance_number from v$instance)
) e, dba_hist_snapshot s
where e.TIME_WAITED_MS > 0
and e.instance_number=s.instance_number
and e.snap_id=s.snap_id
and s.BEGIN_INTERVAL_TIME >= trunc(sysdate-&sysdate_nb_day_begin_interval+1)
and s.BEGIN_INTERVAL_TIME <= trunc(sysdate-&sysdate_nb_day_end_interval+1) order by 1











# Plot the 4 graphs
par(mfrow =c(4,1))
plot(sqevent[,'DATEEVT'],sqevent[,'TIME_WAITED_MS'],type="l",col="blue"
,xaxt="n",main=event,cex.main=2,xlab="",ylab="TIME_WAITED_MS")
Axis(side=1,at=sqevent$DATEEVT,round(skip),format="%Y/%m/%d
%H:%M")
plot(sqevent[,'DATEEVT'],sqevent[,'TOTAL_WAITS'],type="l",col="blue",xa
xt="n",xlab="",ylab="NB_WAITS")
Axis(side=1,at=sqevent$DATEEVT,round(skip),format="%Y/%m/%d
%H:%M")
plot(sqevent[,'DATEEVT'],sqevent[,'MS_PER_WAIT'],type="l",col="blue",xa
xt="n",xlab="",ylab="MS_PER_WAIT")
Axis(side=1,at=sqevent$DATEEVT,round(skip),format="%Y/%m/%d
%H:%M")
hist(sqevent[,'MS_PER_WAIT'],xlab="MS_PER_WAIT",main=NULL,border="
blue")


Query is a little bit complicated (comes from
OEM)




















# compute percentages
pct <- round(dg_space[,'SIZE_GB']/sum(dg_space[,'SIZE_GB'])*100)
# add %
pct <- paste(pct,"%",sep="")
# Add db size to db_name
db_name_size<-paste(dg_space[,'DB_NAME']," (",sep="")
db_name_size<-paste(db_name_size,dg_space[,'SIZE_GB'],sep="")
db_name_size<-paste(db_name_size," GB)",sep="")

# Set the colors
colors<-rainbow(length(dg_space[,'DB_NAME']))
# Plot
pie(dg_space[,'SIZE_GB'], labels = pct, col=colors, main=paste(dg," Disk Group Usage",sep=""))
# Add a legend
legend(x=1.2,y=0.5,legend=db_name_size,fill=colors,cex=0.8)


Basically the script takes a snapshot based on
the v$sysstat view then computes and graphs
the delta with the previous snapshot.
myquery<-"
Select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT, NAME,VALUE,1 VALUE_PER_SEC
from v$sysstat
where name='"
# Keep them
prev_date<<-qoutput[,'DATEEVT']
prev_value<<-qoutput[,'VALUE']
# Launch the loop for the real-time graph
nb_refresh <- as.integer(nb_refresh)
for(i in seq(nb_refresh)) {
# Get the new data
Sys.sleep(refresh_interval)
qoutput<-dbGetQuery(conn,myquery)
# Keep the current value
current_date<-qoutput[,'DATEEVT']
current_value<-qoutput[,'VALUE']
# compute difference between snap for value and value per sec
#qoutput[,'DATEEVT']<-current_date
qoutput[,'VALUE']<-current_value-prev_value


Basically the script takes a snapshot based on
the v$system_event view then computes and
graphs the delta with the previous snapshot.
myquery<-"
Select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as
DATEEVT, EVENT,TOTAL_WAITS,TIME_WAITED_MICRO/1000 as TIME_WAITED_MS,1 MS_PER_WAIT
from v$system_event
where event='"
# Keep them
prev_tw<<-qoutput[,'TIME_WAITED_MS']
prev_twaits<<-qoutput[,'TOTAL_WAITS']
# So we want 4 graphs
par(mfrow =c(4,1))
# Launch the loop for the real-time graph
nb_refresh <- as.integer(nb_refresh)
for(i in seq(nb_refresh)) {
# Get the new data
Sys.sleep(refresh_interval)
qoutput<-dbGetQuery(conn,myquery)
# compute difference between snap for time_waited_ms, total_waits and then compute ms_per_wait
qoutput[,'TIME_WAITED_MS']<-current_tw-prev_tw
qoutput[,'TOTAL_WAITS']<-current_twaits-prev_twaits
myquery<-"
select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT,
wait_class as WAIT_CLASS,
time_waited_micro/1000 as TIME_WAITED_MS,
EVENT as EVENT
from v$system_event where WAIT_CLASS != 'Idle'
union
select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT,
'CPU' as WAIT_CLASS
,sum(value/1000) as TIME_WAITED_MS
,'CPU' as EVENT
from
v$sys_time_model
where
stat_name IN ('background cpu time', 'DB CPU')
"


Sub-graph for the time waited (in ms) per
wait class:


Sub-graph for the wait events distribution
of the wait class having the max time
waited during the last snap:


Sub-graph for the wait class distribution
since the script has been launched:







# Split the screen
no_display<-split.screen( figs = c( 2, 1 ) )
# Split the second screen
no_display<-split.screen( figs = c( 1, 2
), screen=2 )
Much more complicated: source code is
available through my blog.




Retrieve and visualize in real time the output
of my asm_metrics.pl utility.
What is yours ?

Weitere ähnliche Inhalte

Was ist angesagt?

Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres MonitoringDenish Patel
 
Xtrabackup工具使用简介 - 20110427
Xtrabackup工具使用简介 - 20110427Xtrabackup工具使用简介 - 20110427
Xtrabackup工具使用简介 - 20110427Jinrong Ye
 
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
Exadata X3 in action:  Measuring Smart Scan efficiency with AWRExadata X3 in action:  Measuring Smart Scan efficiency with AWR
Exadata X3 in action: Measuring Smart Scan efficiency with AWRFranck Pachot
 
collectd & PostgreSQL
collectd & PostgreSQLcollectd & PostgreSQL
collectd & PostgreSQLMark Wong
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetLucian Oprea
 
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
Cassandra South Bay Meetup - Backup And Restore For Apache CassandraCassandra South Bay Meetup - Backup And Restore For Apache Cassandra
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandraaaronmorton
 
Enable archivelod mode in oracle rac12cR1 with asm location
Enable archivelod mode  in oracle rac12cR1 with asm locationEnable archivelod mode  in oracle rac12cR1 with asm location
Enable archivelod mode in oracle rac12cR1 with asm locationDebasish Nayak
 
In Defense Of Core Data
In Defense Of Core DataIn Defense Of Core Data
In Defense Of Core DataDonny Wals
 
12c SQL Plan Directives
12c SQL Plan Directives12c SQL Plan Directives
12c SQL Plan DirectivesFranck Pachot
 
VirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRVirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRKristofferson A
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsCommand Prompt., Inc
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollPGConf APAC
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internalsaaronmorton
 
Database decommission process
Database decommission processDatabase decommission process
Database decommission processK Kumar Guduru
 
Administering and Monitoring SolrCloud Clusters
Administering and Monitoring SolrCloud ClustersAdministering and Monitoring SolrCloud Clusters
Administering and Monitoring SolrCloud Clusterslucenerevolution
 
Troubleshooting PostgreSQL with pgCenter
Troubleshooting PostgreSQL with pgCenterTroubleshooting PostgreSQL with pgCenter
Troubleshooting PostgreSQL with pgCenterAlexey Lesovsky
 

Was ist angesagt? (20)

PostgreSQL Replication Tutorial
PostgreSQL Replication TutorialPostgreSQL Replication Tutorial
PostgreSQL Replication Tutorial
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
Advanced Postgres Monitoring
Advanced Postgres MonitoringAdvanced Postgres Monitoring
Advanced Postgres Monitoring
 
Xtrabackup工具使用简介 - 20110427
Xtrabackup工具使用简介 - 20110427Xtrabackup工具使用简介 - 20110427
Xtrabackup工具使用简介 - 20110427
 
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
Exadata X3 in action:  Measuring Smart Scan efficiency with AWRExadata X3 in action:  Measuring Smart Scan efficiency with AWR
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
 
collectd & PostgreSQL
collectd & PostgreSQLcollectd & PostgreSQL
collectd & PostgreSQL
 
PostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_CheatsheetPostgreSQL High_Performance_Cheatsheet
PostgreSQL High_Performance_Cheatsheet
 
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
Cassandra South Bay Meetup - Backup And Restore For Apache CassandraCassandra South Bay Meetup - Backup And Restore For Apache Cassandra
Cassandra South Bay Meetup - Backup And Restore For Apache Cassandra
 
Enable archivelod mode in oracle rac12cR1 with asm location
Enable archivelod mode  in oracle rac12cR1 with asm locationEnable archivelod mode  in oracle rac12cR1 with asm location
Enable archivelod mode in oracle rac12cR1 with asm location
 
In Defense Of Core Data
In Defense Of Core DataIn Defense Of Core Data
In Defense Of Core Data
 
12c SQL Plan Directives
12c SQL Plan Directives12c SQL Plan Directives
12c SQL Plan Directives
 
VirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRVirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWR
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
Oracle NOLOGGING
Oracle NOLOGGINGOracle NOLOGGING
Oracle NOLOGGING
 
Rmoug ashmaster
Rmoug ashmasterRmoug ashmaster
Rmoug ashmaster
 
How to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'rollHow to teach an elephant to rock'n'roll
How to teach an elephant to rock'n'roll
 
Apache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra InternalsApache Con NA 2013 - Cassandra Internals
Apache Con NA 2013 - Cassandra Internals
 
Database decommission process
Database decommission processDatabase decommission process
Database decommission process
 
Administering and Monitoring SolrCloud Clusters
Administering and Monitoring SolrCloud ClustersAdministering and Monitoring SolrCloud Clusters
Administering and Monitoring SolrCloud Clusters
 
Troubleshooting PostgreSQL with pgCenter
Troubleshooting PostgreSQL with pgCenterTroubleshooting PostgreSQL with pgCenter
Troubleshooting PostgreSQL with pgCenter
 

Andere mochten auch

Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!BertrandDrouvot
 
Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...
Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...
Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...Szymon Skorupinski
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVMaxym Kharchenko
 
Big Data Analytics with R
Big Data Analytics with RBig Data Analytics with R
Big Data Analytics with RGreat Wide Open
 
Presentation R basic teaching module
Presentation R basic teaching modulePresentation R basic teaching module
Presentation R basic teaching moduleSander Timmer
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with RShareThis
 
R language tutorial
R language tutorialR language tutorial
R language tutorialDavid Chiu
 
Iris data analysis example in R
Iris data analysis example in RIris data analysis example in R
Iris data analysis example in RDuyen Do
 

Andere mochten auch (13)

Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
Automatic Storage Management (ASM) metrics are a goldmine: Let's use them!
 
Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...
Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...
Prepare for the Worst: Reliable Data Protection with Oracle RMAN and Oracle D...
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
 
Introduction To R
Introduction To RIntroduction To R
Introduction To R
 
Big Data Analytics with R
Big Data Analytics with RBig Data Analytics with R
Big Data Analytics with R
 
Big data analytics using R
Big data analytics using RBig data analytics using R
Big data analytics using R
 
Presentation R basic teaching module
Presentation R basic teaching modulePresentation R basic teaching module
Presentation R basic teaching module
 
Antagonistas adrenergicos
Antagonistas adrenergicosAntagonistas adrenergicos
Antagonistas adrenergicos
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
 
R for data analytics
R for data analyticsR for data analytics
R for data analytics
 
Language R
Language RLanguage R
Language R
 
R language tutorial
R language tutorialR language tutorial
R language tutorial
 
Iris data analysis example in R
Iris data analysis example in RIris data analysis example in R
Iris data analysis example in R
 

Ähnlich wie Example R usage for oracle DBA UKOUG 2013

Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Аліна Шепшелей
 
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...Inhacking
 
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceViktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceLviv Startup Club
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptDave Stokes
 
GDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesGDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesSergey Tarasevich
 
Nko workshop - node js & nosql
Nko workshop - node js & nosqlNko workshop - node js & nosql
Nko workshop - node js & nosqlSimon Su
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRsquared Academy
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Miguel González-Fierro
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationBen Hall
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in CassandraJairam Chandar
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryWilliam Candillon
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 
[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data productIgor Lozynskyi
 

Ähnlich wie Example R usage for oracle DBA UKOUG 2013 (20)

ROracle
ROracle ROracle
ROracle
 
Lecture17
Lecture17Lecture17
Lecture17
 
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
Vitalii Bondarenko HDinsight: spark. advanced in memory big-data analytics wi...
 
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
SE2016 BigData Vitalii Bondarenko "HD insight spark. Advanced in-memory Big D...
 
Viktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning ServiceViktor Tsykunov: Azure Machine Learning Service
Viktor Tsykunov: Azure Machine Learning Service
 
Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
 
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScriptJavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
JavaScript and Friends August 20th, 20201 -- MySQL Shell and JavaScript
 
GDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokesGDG DevFest 2015 - Reactive approach for slowpokes
GDG DevFest 2015 - Reactive approach for slowpokes
 
Nko workshop - node js & nosql
Nko workshop - node js & nosqlNko workshop - node js & nosql
Nko workshop - node js & nosql
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
RMySQL Tutorial For Beginners
RMySQL Tutorial For BeginnersRMySQL Tutorial For Beginners
RMySQL Tutorial For Beginners
 
Analytics with Spark
Analytics with SparkAnalytics with Spark
Analytics with Spark
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
Real World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS ApplicationReal World Lessons on the Pain Points of Node.JS Application
Real World Lessons on the Pain Points of Node.JS Application
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
Jdbc
JdbcJdbc
Jdbc
 
Cutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQueryCutting Edge Data Processing with PHP & XQuery
Cutting Edge Data Processing with PHP & XQuery
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Advanced Cassandra
Advanced CassandraAdvanced Cassandra
Advanced Cassandra
 
[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product
 

Kürzlich hochgeladen

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Kürzlich hochgeladen (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Example R usage for oracle DBA UKOUG 2013

  • 2.        Oracle DBA since 1999 OCP 9i,10g,11g Rac certified Expert Exadata certified implementation specialist Blogger since 2012 @bertranddrouvot BasketBall fan
  • 3.      Some examples of R usage with the oracle database From a DBA point of view Retrieve system statistics/wait events with some AWR queries Real time Data Dashboard of the database activity
  • 4.    R installation R programing R studio (powerful and productive user interface for R)
  • 5.   Because R is a powerful tool for statistical analysis with graphing and plotting packages built in. Furthermore, R can connect to Oracle via a JDBC package which makes importing data very easy.
  • 8. select s.begin_interval_time,sta.stat_name,sta.VALUE, round(((sta.VALUE)/ ( (extract(day from s.END_INTERVAL_TIME)-extract(day from s.BEGIN_INTERVAL_TIME))*86400 + (extract(hour from s.END_INTERVAL_TIME)-extract(hour from s.BEGIN_INTERVAL_TIME))*3600 + (extract(minute from s.END_INTERVAL_TIME)-extract(minute from s.BEGIN_INTERVAL_TIME))*60 + (extract(second from s.END_INTERVAL_TIME)-extract(second from s.BEGIN_INTERVAL_TIME)) ) ),2) VALUE_PER_SEC from ( select instance_number,snap_id,stat_name, value - first_value(value) over (partition by stat_name order by snap_id rows 1 preceding) "VALUE" from dba_hist_sysstat where stat_name like nvl('&stat_name',stat_name) and instance_number = (select instance_number from v$instance) ) sta, dba_hist_snapshot s where sta.instance_number=s.instance_number and sta.snap_id=s.snap_id and s.BEGIN_INTERVAL_TIME >= trunc(sysdate-&sysdate_nb_day_begin_interval+1) and s.BEGIN_INTERVAL_TIME <= trunc(sysdate-&sysdate_nb_day_end_interval+1) order by s.begin_interval_time asc;
  • 9.
  • 10.
  • 11.         # Plot the 4 graphs par(mfrow =c(4,1)) plot(sqstat[,'DATEEVT'],sqstat[,'VALUE'],type="l",col="blue" ,xaxt="n",main=stat_name,cex.main=2,xlab="",ylab="VAL UE") Axis(side=1,at=sqstat$DATEEVT,round(skip),format="%Y/ %m/%d %H:%M") plot(sqstat[,'DATEEVT'],sqstat[,'VALUE_PER_SEC'],type="l",c ol="blue",xaxt="n",xlab="",ylab="VALUE_PER_SEC") Axis(side=1,at=sqstat$DATEEVT,round(skip),format="%Y/ %m/%d %H:%M") hist(sqstat[,'VALUE'],xlab="VALUE",main=NULL,border="bl ue") hist(sqstat[,'VALUE_PER_SEC'],xlab="VALUE_PER_SEC",main =NULL,border="blue")
  • 12. select e.WAIT_CLASS,e.event_name,s.begin_interval_time,e.TOTAL_WAITS,e.TIME_WAITED_MS,e.TIME_WAITED_MS / TOTAL_WAITS "MS_PER_WAIT" from ( select instance_number,snap_id,WAIT_CLASS,event_name, total_waits - first_value(total_waits) over (partition by event_name order by snap_id rows 1 preceding) "TOTAL_WAITS", (time_waited_micro - first_value(time_waited_micro) over (partition by event_name order by snap_id rows 1 preceding))/1000 "TIME_WAITED_MS" from dba_hist_system_event where WAIT_CLASS like nvl('&WAIT_CLASS',WAIT_CLASS) and event_name like nvl('&event_name',event_name) and instance_number = (select instance_number from v$instance) ) e, dba_hist_snapshot s where e.TIME_WAITED_MS > 0 and e.instance_number=s.instance_number and e.snap_id=s.snap_id and s.BEGIN_INTERVAL_TIME >= trunc(sysdate-&sysdate_nb_day_begin_interval+1) and s.BEGIN_INTERVAL_TIME <= trunc(sysdate-&sysdate_nb_day_end_interval+1) order by 1
  • 13.
  • 14.          # Plot the 4 graphs par(mfrow =c(4,1)) plot(sqevent[,'DATEEVT'],sqevent[,'TIME_WAITED_MS'],type="l",col="blue" ,xaxt="n",main=event,cex.main=2,xlab="",ylab="TIME_WAITED_MS") Axis(side=1,at=sqevent$DATEEVT,round(skip),format="%Y/%m/%d %H:%M") plot(sqevent[,'DATEEVT'],sqevent[,'TOTAL_WAITS'],type="l",col="blue",xa xt="n",xlab="",ylab="NB_WAITS") Axis(side=1,at=sqevent$DATEEVT,round(skip),format="%Y/%m/%d %H:%M") plot(sqevent[,'DATEEVT'],sqevent[,'MS_PER_WAIT'],type="l",col="blue",xa xt="n",xlab="",ylab="MS_PER_WAIT") Axis(side=1,at=sqevent$DATEEVT,round(skip),format="%Y/%m/%d %H:%M") hist(sqevent[,'MS_PER_WAIT'],xlab="MS_PER_WAIT",main=NULL,border=" blue")
  • 15.  Query is a little bit complicated (comes from OEM)
  • 16.
  • 17.
  • 18.
  • 19.               # compute percentages pct <- round(dg_space[,'SIZE_GB']/sum(dg_space[,'SIZE_GB'])*100) # add % pct <- paste(pct,"%",sep="") # Add db size to db_name db_name_size<-paste(dg_space[,'DB_NAME']," (",sep="") db_name_size<-paste(db_name_size,dg_space[,'SIZE_GB'],sep="") db_name_size<-paste(db_name_size," GB)",sep="") # Set the colors colors<-rainbow(length(dg_space[,'DB_NAME'])) # Plot pie(dg_space[,'SIZE_GB'], labels = pct, col=colors, main=paste(dg," Disk Group Usage",sep="")) # Add a legend legend(x=1.2,y=0.5,legend=db_name_size,fill=colors,cex=0.8)
  • 20.  Basically the script takes a snapshot based on the v$sysstat view then computes and graphs the delta with the previous snapshot.
  • 21.
  • 22.
  • 23. myquery<-" Select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT, NAME,VALUE,1 VALUE_PER_SEC from v$sysstat where name='" # Keep them prev_date<<-qoutput[,'DATEEVT'] prev_value<<-qoutput[,'VALUE'] # Launch the loop for the real-time graph nb_refresh <- as.integer(nb_refresh) for(i in seq(nb_refresh)) { # Get the new data Sys.sleep(refresh_interval) qoutput<-dbGetQuery(conn,myquery) # Keep the current value current_date<-qoutput[,'DATEEVT'] current_value<-qoutput[,'VALUE'] # compute difference between snap for value and value per sec #qoutput[,'DATEEVT']<-current_date qoutput[,'VALUE']<-current_value-prev_value
  • 24.  Basically the script takes a snapshot based on the v$system_event view then computes and graphs the delta with the previous snapshot.
  • 25.
  • 26. myquery<-" Select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT, EVENT,TOTAL_WAITS,TIME_WAITED_MICRO/1000 as TIME_WAITED_MS,1 MS_PER_WAIT from v$system_event where event='" # Keep them prev_tw<<-qoutput[,'TIME_WAITED_MS'] prev_twaits<<-qoutput[,'TOTAL_WAITS'] # So we want 4 graphs par(mfrow =c(4,1)) # Launch the loop for the real-time graph nb_refresh <- as.integer(nb_refresh) for(i in seq(nb_refresh)) { # Get the new data Sys.sleep(refresh_interval) qoutput<-dbGetQuery(conn,myquery) # compute difference between snap for time_waited_ms, total_waits and then compute ms_per_wait qoutput[,'TIME_WAITED_MS']<-current_tw-prev_tw qoutput[,'TOTAL_WAITS']<-current_twaits-prev_twaits
  • 27. myquery<-" select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT, wait_class as WAIT_CLASS, time_waited_micro/1000 as TIME_WAITED_MS, EVENT as EVENT from v$system_event where WAIT_CLASS != 'Idle' union select to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') as DATEEVT, 'CPU' as WAIT_CLASS ,sum(value/1000) as TIME_WAITED_MS ,'CPU' as EVENT from v$sys_time_model where stat_name IN ('background cpu time', 'DB CPU') "
  • 28.
  • 29.  Sub-graph for the time waited (in ms) per wait class:
  • 30.  Sub-graph for the wait events distribution of the wait class having the max time waited during the last snap:
  • 31.  Sub-graph for the wait class distribution since the script has been launched:
  • 32.
  • 33.      # Split the screen no_display<-split.screen( figs = c( 2, 1 ) ) # Split the second screen no_display<-split.screen( figs = c( 1, 2 ), screen=2 ) Much more complicated: source code is available through my blog.
  • 34.   Retrieve and visualize in real time the output of my asm_metrics.pl utility. What is yours ?