Oracle Database Performance Tuning
Using oratop
Tips and tricks
Sandesh Rao
VP AIOps for the Autonomous
@sandeshr
https://www.linkedin.com/in/raosandesh/
https://www.slideshare.net/SandeshRao4
What is oratop
A text-based interface like “top”, which can
be run against Real Application Cluster
(RAC) or non-RAC databases
It provides the ability to monitor the
database in near real time
Visual layout
(1) Database
(2) Instance activity
(3) AWR like
“Top 5 Timed Events”
(4) Process or SQL
Command line mode
$ export ORACLE_HOME=<path>
$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib
$ export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/suptools/oratop:$PATH
$ ./oratop –h
oratop: Release 16.5.1
The oratop program provides a dynamic near real-time view of an open database
It also provides a limited on-line interactive interface.
Usage:
oratop [ [Options] [Logon] ]
Logon: {username[@connect_identifier] | / } [AS SYSDBA]
Password is prompted and the connect_identifier is TNS/ EZconnect
Options:
-b: batch mode. Used with –n iteration (default is console)
-n: maximum number of iterations (requires a value)
-o: Write console output to a file (in batch mode)
-i: interval delay (requires a value, default: 5)
-r: real-time (RT) wait events. (section 3, default: Cumulative)
-m: Session/Process MODULE/ACTION (default: USERNAME/PROGRAM)
-s: SQL mode. (section 4, default: session/process mode)
-f: detailed format, 132 columns. (default: standard, 80 columns)
-v: oratop release version number
-h: this help
Command line mode
$ export ORACLE_HOME=<path>
$ export LD_LIBRARY_PATH=$ORACLE_HOME/lib
$ export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/suptools/oratop:$PATH
$ ./oratop –h
oratop: Release 16.5.1
The oratop program provides a dynamic near real-time view of an open database
It also provides a limited on-line interactive interface.
Usage:
oratop [ [Options] [Logon] ]
Logon: {username[@connect_identifier] | / } [AS SYSDBA]
Password is prompted and the connect_identifier is TNS/ EZconnect
Options:
-b: batch mode. Used with –n iteration (default is console)
-n: maximum number of iterations (requires a value)
-o: Write console output to a file (in batch mode)
-i: interval delay (requires a value, default: 5)
-r: real-time (RT) wait events. (section 3, default: Cumulative)
-m: Session/Process MODULE/ACTION (default: USERNAME/PROGRAM)
-s: SQL mode. (section 4, default: session/process mode)
-f: detailed format, 132 columns. (default: standard, 80 columns)
-v: oratop release version number
-h: this help
Login
Connection method is like sqlplus
$ oratop / as sysdba
Connecting “ / as sysdba“ is allowed only for bequeath connections
The remote database requires setting the parameter “REMOTE_LOGIN_PASSWORDFILE”
paired with the availability of an Oracle password file.
Login
TNS:
export TNS_ADMIN and connect with a TNS alias name as defined in tnsnames.ora
EZConnect, example:
oratop sys@rmtdbhost:1521/db1.domain.com as sysdba
TWO_TASK can be set with any of the above for ease of use, example
$ export TWO_TASK= rmtdbhost:1521/db1.domain.com
$ ./oratop sys as sysdba
oratop: Release 16.5.1 Production on Fri Feb 11 05:54:50 UTC 2022
Copyright (c) 2011, Oracle. All rights reserved.
Enter password:
Interactive Mode
Options can be seen after starting the utility followed by pressing the keyboard key ‘h’
oratop: Release 16.5.1
Interactive Keys: [default]
f : toggle between [standard] & detailed format
r : toggle between [Cumulative ©] & Real-Time (RT) (section 3)
s : switch to SQL mode (section 4)
p : switch to [session/process] mode (section 4)
m : Toggle session [USERNAME/PROGRAM] & MODULE/ACTION (sections 4)
t : tablespace information (N/A on standby)
x : SQL plan table (requires a value)
I : refresh interval, requires value in seconds [5]
q : quit/ exit program
Esc : pause.
Symbols:
(B)tyle, (K)illo, (M)ega, (G)iga, (T)err, [PEXY]
(u)micro, (m)illi, (s)econd, minu(t)e, (h)our, (d)ay, (y)ear
[60s/ 15s] – metric interval size, else current.
Abbreviations Help Menu:
Section 1 – DATABASE .. [1]
Section 2 – INSTANCE .. [2]
Section 3 – DB WAIT EVENTS .. [3]
Section 4 – SESSION/PROCESS .. [4]
Quit Help .. (q|Q)
Enter selection number:
Miscellaneous
Values appearing in RED color
Values flagged and highlighted in red color are merely an emphasis of warning
Header’s “archivelog” and “er” (incidents) These two values are static, they are acquired once upon
start of monitoring only. They are not auto refreshed because the first incur expensive recursive query
and the second adds to diagnosability database waits
Header’s %DCP
Column “%DCP” (in section 2) is the database instance cpu usage as %CPU of the host
Tablespaces listing
A list of all the tablespaces (cdb and pdb) can be obtained online with keyboard key press ‘t’
Wait Events (section 3)
Keyboard key press ‘r’ will toggle the wait event section between Cumulative and Realtime.
For C, the stats shown is the accumulation since the last database restart
Miscellaneous
Detailed format (long)
Note. in RAC environment, while section 2 (instance section) is restricted to the top 5 instances in the
text-based user interface, all of the available instances will be listed in the batch mode.
Batch Mode
Batch mode is applicable at the command line with the relevant input options.
$ ./oratop / sysdba -bn1
oratop: Release 16.5.1 Production on Fri Apr 28 19:42:40 UTC 2023
Copyright (c) 2011, Oracle. All rights reserved.
Enter password:
Connecting
Cycle 1 - oratop: Release 16.5.1 Production on Fri Apr 28 19:42:49 UTC 2023
Oracle 21c - 19:41:56 Pri r/w cdbs up: 13h, 12 sn, 4G sga, 10%fra, 15%db
ID %CPU LOAD AAS ASC ASI ASW ISW IORT MBPS %FRE PGA UCPS SQRT %DBC %DBW
-------------------------------------------------------------------------------
1 51 3 1 0 0 6 6 17m 2 8 834M 42 1m 4 11
EVENT (C) T/O WAIT TIME AVG %DBT WAIT_CLASS
-------------------------------------------------------------------------------
SQL*Net more data from client 31k 1d 3s 93 Network
SQL*Net message from dblink 505k 39t 5m 2 Network
DB CPU 39t 2
oracle thread bootstrap 9k 27t 186m 2 Other
db file sequential read 35k 4t 6m 0 User I/O
ID SID SPID USR PROG S OPN SQLID/BLOCKER E/T %CPU PGA ACT EVENT/OB W/T
-------------------------------------------------------------------------------
1 792 517 TPC tpcc D PL/ 582r1jmmm3tgj 3s 3 4M INA SQL*Net 3s
1 802 439 TPC tpcc D PL/ 582r1jmmm3tgj 184m 3 4M INA SQL*Net 184m
1 418 413 TPC tpcc D PL/ 582r1jmmm3tgj 185m 1 4M INA SQL*Net 185m
Cycle 2 - oratop: Release 16.5.1 Production on Fri Apr 28 19:42:54 UTC 2023
Oracle 21c - 19:41:56 Pri r/w cdbs up: 13h, 12 sn, 4G sga, 10%fra, 15%db
ID %CPU LOAD AAS ASC ASI ASW ISW IORT MBPS %FRE PGA UCPS SQRT %DBC %DBW
-------------------------------------------------------------------------------
1 51 3 1 0 0 6 6 17m 2 8 834M 42 1m 4 11
EVENT (C) T/O WAIT TIME AVG %DBT WAIT_CLASS
SQL
SQL (key press ‘s’)
SQL Plan
SQL (key press ‘x’)
Miscellaneous
Exiting
To quit the program gracefully, user may press keyboard keys: "q" or "Q", or Esc key. A Ctrl+c to abort
forcibly. In all cases, proper database logout is performed
Unprivileged user
A typical error encountered by a non-privileged user upon connection to the database using the tool
is “ORA-00942: table or view does not exist”
To allow the non-privileged user to use oratop, the system administrator with a DBA role may issue
the following grant: “GRANT SELECT ANY DICTIONARY TO ;”
Standby or mounted database instance
• STANDBY - key press “t” for “TABLESPACE INFORMATION” will not return any rows. Reason: BUG
27841703
• MOUNTED Instance – Section 2 will show inst_id highlighted in red color. Reason: Required
statistics is not available until instance is opened.
Monitoring a database every 10 seconds
Monitor a local database:
$ ./oratop -i 10 / as sysdba
Monitoring a remote database:
$ ./oratop -i 10 username/password@tns_alias
or
$ ./oratop -i 10 system/manager@tns_alias
Running from AHF
tfactl menu..
tfactl menu..
tfactl menu..
f : toggle between [standard] & detailed format
r : toggle between [Cumulative ©] & Real-Time (RT) (section 3)
m : Toggle session [USERNAME/PROGRAM] & MODULE/ACTION (sections 4)
t : tablespace information (N/A on standby)
x : SQL plan table (requires a value)
I : refresh interval, requires value in seconds [5]
(h) Help menu
1 4
7
Oracle major Read write, read
only, w/apply Number user
version sessions 10 13
2 (active)
Diag active % used flashback
Current time from 8 problem count 11 recovery area 14
system metric 5 Total Archivelog mode
Number of
Name instances database
9 Size 15
12
3 Role Number of Largest system Database
6 pluggable utilization
(Primary, global area
Physical databases (%busy)
Database
standby) uptime
17 Logical
1 5 Avg Avg active 14
11 reads / 20 User calls 26
active 8 sessions
Instance I/O requests sec 23 / sec
sessions waiting Temp space Total PGA Database
ID / second
used allocated WAIT
2 6 (DB R/W)
9 12 18 (%Host)
CPU Active Inactive 15 GC CR+ 21
Count sessions on I/O Response 24
3 sessions current
CPU % CPU Time Physical Network
waiting or block SQL service
Busy (avg sync read total traffic
sleeping received / response time
single-block IO request (bytes) /
sec / call
7 read latency) / sec sec
4 10 16
Avg active 13 19 22
sessions Redo Physical
Current 25
waiting on created I/O write Shared User
OS load
I/O per sec through total IO pool free trans’ / Database
put in request / % sec CPU
MB /sec sec (%Host)
Number
Wait event name 2 5
sessions
1 (real time mode) waiting Avg wait
time
3 6
Total number % of
of waits for database
the event time
4 7
Total wait Name of
time wait class
Thank you
Any Questions?
Sandesh Rao
VP AIOps for the Autonomous Database
@sandeshr
https://www.linkedin.com/in/raosandesh/
https://www.slideshare.net/SandeshRao4