Objects that take more than 5% of the buffer cache:
select o.owner, o.object_type, o.object_name, count(b.objd)
from v$bh b, dba_objects o
where b.objd = o.object_id
group by o.owner, o.object_type, o.object_name
having count (b.objd) > (select to_number(value*.05)
from v$parameter
where name = 'db_block_buffers');
select n.name, s.xacts, s.gets, s.waits, s.extents, s.wraps, s.extends, s.hwmsize from v$rollname n, v$rollstat s where n.usn = s.usn;
select segment_name, initial_extent, next_extent, min_extents from dba_rollback_segs;
Number of data blocks used by a transaction for its undo/redo information
select max(used_ublk) from v$transaction;
How much parsing has your system been doing?
select a.value total_parses, b.value hard_parses, a.value - b.value soft_parses, round((b.value/a.value)*100,1) hard_parse_percentage from v$sysstat a, v$sysstat b where a.name = 'parse count (total)' and b.name = 'parse count (hard)';
Are SQL statements being pushed from the library cache too often:
select sum(reloads)/sum(pins) from v$librarycache;
Show how much memory objects take in your shared pool:
select name, sharable_mem
from v$db_object_cache
where type in ('PACKAGE', 'PACKAGE_BODY', 'FUNCTION', 'PROCEDURE')
order by sharable_mem desc;
Put an object into the Keep pool:
exec dbms_shared_pool.keep('STANDARD');
select name, value from v$sysstat where name like '%sort%';
select tablespace_name, current_users, total_extents, total_blocks, used_extents, used_blocks from v$sort_segment;
Either set up statspack ($ORACLE_HOME/rdbms/admin/spdoc.txt) or take a delta of V$SYSTEM_EVENT:
drop table sys_event_start; drop table sys_event_end; create table sys_event_start as select * from v$system_event; -- Wait a while create table sys_event_end as select * from v$system_event; -- View the deltas select e1.event, (e2.total_waits-e1.total_waits) "Delta Waits", (e2.total_timeouts-e1.total_timeouts) "Delta Timeouts", (e2.time_waited-e1.time_waited) "Delta Time Waited", (e2.average_wait-e1.average_wait) "Delta Average Wait" from sys_event_start e1, sys_event_end e2 where e1.event = e2.event;
Find out what is happening on the session level. You probably want to replace the s.username is not null clause with something that is meaningful to you. If you remove it altogether, you will also get the events associated with background processes such as PMON and SMON.
select s.username, s.program, s.status,
e.event, e.total_waits, e.total_timeouts,
e.time_waited, e.average_wait
from v$session s, v$session_event e
where s.sid = e.sid
and e.event like 'latch free'
and s.status = 'ACTIVE'
and s.username is not null;
Look at statistics of some common wait events:
select *
from v$system_event
where event in ('latch free',
'log file sync',
'log file parallel write',
'control file parallel write',
'db file sequential read');
Find the wait events for currently connected sessions. Run multiple times:
select w.sid, s.username, w.event, p1text, p1, p2text, p2,
p3text, p3, w.wait_time, w.state, w.seconds_in_wait
from v$session s, v$session_wait w
where s.sid = w.sid
and w.event not like 'SQL*Net%'
and s.username is not null
order by seconds_in_wait;
Wait Parameters for latch free waits
| Parameter | Description |
| p1 | SGA address of the latch required; corresponds to the ADDR column of V$LATCH_PARENT and V$LATCH_CHILDREN |
| p2 | Type of the latch; corresponds to the LATCH# column of V$LATCH et al. |
| p3 | Number of times the process has slept during this attempt to acquire the latch |
You should set timed_statistics to true in your init.ora. Negligable overhead and gives you a lot more meaningfull figures.
alter session set sql_trace=true;
or for another session:
select sid, serial#
from v$session
where username= 'DIRK';
SID SERIAL#
---------- ----------
35 3
execute dbms_system.set_sql_trace_in_session('35', '3', TRUE);
Turn it off with:
execute dbms_system.set_sql_trace_in_session('35', '3', FALSE);
Who is connected to the DB, and what can you tell me about their sessions? select s.username||','||s.sid uname, s.serial# serial, s.process, s.terminal, to_char(s.logon_time, 'Dy HH24:MI') logon_time, s.status, s.module from v$session s where s.type = 'USER' and s.username is not null and s.username like :your_usr_name_here order by username; You can then: alter system kill session 'sid,serial#';
update
(select columnName, value
from name, lookup
where name.keyname = lookup.keyname
and lookup.othercolumn = :other_value)
set column_name = value;
select substr( a.file_name,
instr(a.file_name,'/',-1)) file_name,
round(bytes/1024/1024) mBytes,
round(nvl(b.free,0)/1024/1024) Free,
round( (a.bytes-nvl(b.free,0))/1024/1024) used
from dba_data_files a,
(select sum(bytes) free, file_id
from dba_free_space
group by file_id ) b
where a.file_id = b.file_id(+);
* How full are my tablespaces?
select FS.tablespace_name, File_Name, SUM(FS.Blocks) as remaining, DF.Blocks as total_space, SUM(FS.bytes), maxextend*8192, inc*8192
from DBA_FREE_SPACE FS, DBA_DATA_FILES DF, SYS.FILEXT$
where
FS.File_Id = DF.File_id and FS.File_id=File#(+)
group by FS.tablespace_name, File_Name, DF.Blocks, maxextend, inc
order by FS.tablespace_name, File_Name
select s.sid,n.name,s.value
from v$sesstat s,v$statname n
where n.name = 'redo blocks written'
and s.statistic#=n.statistic#
order by value;
select sql_text, parse_calls, executions from v$sqlarea order by parse_calls;
Statements with large number of buffer gets
select address, hash_value, buffer_gets, executions,
buffer_gets/executions "gets/exec", sql_text
from v$sqlarea
where buffer_gets > 50000
and executions > 0
order by 3;
Get the parse time CPU and CPU figures used by this session:
select *
from v$sysstat
where name in ('parse time cpu', 'parse time elapsed', 'parse count (hard)');
Create primary keys so they can be disabled without the corresponding index being dropped:
create table foobar ( col1 number constraint foobar_col1_pk primary key deferrable initially immediate -- using index tablespace indx , col2 varchar2(5));