Archive

Archive for the ‘diagnostic’ Category

AWR – automatic workload repository

17. July 2011 1 comment

to change the collection interval and retention policy

exec dbms_workload_repository.modify_snapshot_settings ( retention => 20160, -
interval => 30);

example above will change to 14 days (value in minutes) with 30mins snapshots

retention (default  8 days) and interval (default 1 hour)  in minutes

be aware – increasing the retention time or increase the frequence of snapshots the sysaux tablespace will increase also !

to show the current settings or the latest snapshot

col systimestamp format a35
col most_recent_snap_time format a25
col snap_interval format a17
col retention format a17

select systimestamp, most_recent_snap_time, snap_interval, retention
 from wrm$_wr_control 
  where dbid = (select dbid from v$database);

create manually a snapshot

exec dbms_workload_repository.create_snapshot

enable/disable Diagnostic&Tuning pack

Read more…

Categories: diagnostic Tags: ,

invalidate cursor in shared pool

Sometimes it’s necessary to invalidate a specific cursor in shared pool.

In the past you had to flush the complete shared pool – which caues ALL sql statements were flushed 😦

In the package dbms_shared_pool you can flush a SINGLE cursor.

Read more…

event 10046 – tracing sessions

how to trace session by
– alter session
– oradebug
– logon trigger

tracefiles will be placed in user_dump_dest (10g) or in diag_dest/db/inst/trace (11g)

Session Tracing

alter session set max_dump_file_size = unlimited;
alter session set tracefile_identifier='tr10046';
alter session set events '10046 trace name context forever, level 12';

Read more…

Categories: diagnostic Tags: , ,

tkprof – analyze tracefiles

After creating some traces (e.g. via event 10046)  you can analyze those traces with tkprof

tkprof <input tracefile> <output file>  aggregate=no sys=no explain=username/password

sys=no                 hiddes the recursive calls
aggregate=no    doesn’t aggregate reoccured statements to one summary

with sort=xxxx,yyyy,zzzz you can sort the output

     prscnt  number of times parse was called
     prscpu  cpu time parsing
     prsela  elapsed time parsing
     prsdsk  number of disk reads during parse
     prsqry  number of buffers for consistent read during parse
     prscu   number of buffers for current read during parse
     prsmis  number of misses in library cache during parse

     execnt  number of execute was called
     execpu  cpu time spent executing
     exeela  elapsed time executing
     exedsk  number of disk reads during execute
     exeqry  number of buffers for consistent read during execute
     execu   number of buffers for current read during execute
     exerow  number of rows processed during execute
     exemis  number of library cache misses during execute

     fchcnt  number of times fetch was called
     fchcpu  cpu time spent fetching
     fchela  elapsed time fetching
     fchdsk  number of disk reads during fetch
     fchqry  number of buffers for consistent read during fetch
     fchcu   number of buffers for current read during fetch
     fchrow  number of rows fetched
Categories: diagnostic Tags: , ,

event 10053 – obtaining optimizer computations

to see how the oracle optimizer generates the execution plan  use the event 10053

alter session set max_dump_file_size = unlimited;
alter session set tracefile_identifier='tr10053';
alter session set events='10053 trace name context forever, level 1';

the tracefile will be written to user_dump_dest (10.2) or in <diag_dest>/rdbms/<database>/<instance>/trace

bulk commit

For bulk operations it’s helpfull to commit frequently to avoid ora-1555 (snapshot too old) and avoid long lockings.
with the following pl/sql-block you can handle this easier

DECLARE
 currentcursor NUMBER := 0;
 total NUMBER := 0;
CURSOR delete_current_record IS
 SELECT rowid FROM BIGEMP;
BEGIN
 FOR rec IN delete_current_record LOOP
 DELETE FROM BIGEMP
 WHERE rowid = rec.rowid;
 total := total + 1;
currentcursor := currentcursor + 1;
 IF (currentcursor &gt;= 10000) THEN
 COMMIT;
 currentcursor := 0;
 END IF;
 END LOOP;
 COMMIT;
 END;
 /
Categories: diagnostic

ADR – Automatic Diagnostic Repository

Changing listener-log directory

to change the directory of listener.xml in 11g
set in listener.ora

ADR_BASE_<listenername>=directory

e.g.
ADR_BASE_LISTENER=/var/opt/oracle

the informations will be written to  e.g.

/var/opt/oracle/diag/tnslsnr/server/listener/alert/log.xml

Categories: diagnostic Tags:

additional events

Cursor tracing

to find the hash_value of the parent cursor for adress
select sql_text, hash_value
from v$sqlarea where sql_id='<sql_id>’;

turn on tracing:
alter session set events ‘immediate trace name cursortrace level 99172,  address <hash_value>’;

turn off tracing
alter system set events ‘immediate trace name cursortrace level 2147483648, address 1’;

Categories: diagnostic Tags: