Gene's Notes

Being a DBA is just like being a rock star - except for the groupies, and the music, and the private jets. OK - it's not much like being a rock star.

Name:
Location: Columbus, GA, United States

Friday, August 07, 2009

Who's blocking now?

It's always good to remember that every screen in Oracle Enterprise Manager, or Quest Spotlight, or other GUI tools, is really the result of a SQL select statement. There is power in knowing what the tools are actually doing, and what data dictionary views are really being accessed. Here's a little one that gives the DBA the information on who's session is blocking someone elses:

select s1.username || '@' || s1.machine
|| ' ( SID=' || s1.sid || ' ) is blocking '
|| s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
from v$lock l1, v$session s1, v$lock l2, v$session s2
where s1.sid=l1.sid and s2.sid=l2.sid
and l1.BLOCK=1 and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2;

BLOCKING_STATUS
-----------------------------------------
gene@myserver ( SID=33 ) is blocking joe@otherserver ( SID=55 )

Once you have that information, you can investigate further, and take action.
The action can be anything from going over to someone's cubicle and having them press the SAVE button, to killing a session.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home