I recently came upon Arup Nanda's series on performance tuning, and it contains some really good info especially for someone like me who hasn't really done any tuning for day-to-day performance issues. The first article focuses on gleaming info from v$session regarding states, blocking sessions, etc. So this is just condensing most of the queries used in the article, which might seem like things he already posted, but I guess it's mostly just for my reference for future use :)
To get the most basic information based on the username:
To get the most basic information based on the username:
select SID, state from v$session where
username='<username>';
select SID, state, event from v$session
where username='<username>';
select sid,
decode(state,
'WAITING','Waiting',
'Working') state,
decode(state,
'WAITING','So far '||seconds_in_wait,
'Last waited '||wait_time/100)||
' secs for '||event
"Description",
from v$session
where username='<username>';
The above script considers anything other than 'WAITING' to be 'working'. With regards to the EVENT value, there are two values that can be possibly ignored.
- SQL*Net message from client - Can be misleading, could be idle, could be network slow.
- rdbms ipc message - event status for sessions that are really idle.
To show who's blocking who:
To find out information about the object being contested upon:
And you can combine the 2 queries if wanted:
To find the query that was being run:
The query above may show no results, as the query in question may have been aged out of the shared pool. Was unlucky first few times running this, it took me awhile to confirm that it was indeed aged out, even though I had just run the query a few seconds before.
select blocking_session,
blocking_instance
from v$session
where sid=<n>;
select row_wait_obj#,
row_wait_file#,
row_wait_block#,
row_wait_row#
from v$session
where sid=<n>;
select owner,
object_type,
object_name,
data_object_id
from dba_objects
where object_id=<row_wait_block#);
select owner,
object_type,
object_name,
data_object_id
from dba_objects
where object_id=(
select row_wait_obj# from v$session
where sid=<n>;
select sql_fulltext
from v$sql
where sql_id = (
select sql_id from v$session where
sid=<n>;
No comments:
Post a Comment