Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query to find blocking sessions in RAC returning duplicate rows

flying_penguinSep 7 2017 — edited Sep 7 2017

11.2.0.4 in RHEL 6.5

I have the following query to list the blocking sessions' SID, Serial and Instance_ID for a RAC DB.

But, it is returning duplicates like below. Is there a way to remove the duplicates without using DISTINCT ? ie by adding another join condition or something?

I know its difficult to find a DB with lot of blocking sessions , so you volunteers might not be able to test this query. So, a rough guess will do

SELECT gvh.SID sessid, gvs.serial# serial,

                    gvh.inst_id instance_id

               FROM gv$lock gvh, gv$lock gvw, gv$session gvs

              WHERE (gvh.id1, gvh.id2) IN (SELECT id1, id2

                                             FROM gv$lock

                                            WHERE request = 0

                                           INTERSECT

                                           SELECT id1, id2

                                             FROM gv$lock

                                            WHERE lmode = 0)

                AND gvh.id1 = gvw.id1

                AND gvw.inst_id = gvh.inst_id --- added to remove duplicate rows. But, didn't help

                AND gvh.id2 = gvw.id2

                AND gvh.request = 0

                AND gvw.lmode = 0

                AND gvh.SID = gvs.SID

                AND gvh.inst_id = gvs.inst_id;

    SESSID     SERIAL INSTANCE_ID

---------- ---------- -----------

      5708      13979           3

      5708      13979           3

      3343      51141           3

      3343      51141           3

      7321       8978           3

      6284       4387           3

      1341      23095           3

      6941      25391           3

      6941      25391           3

      6083      14875           3

.

.

.

<output snipped>

This post has been answered by BPeaslandDBA on Sep 7 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 5 2017
Added on Sep 7 2017
3 comments
519 views