【TUNE_ORACLE】列出NL(NESTED LOOPS)被驅動表走了全表掃描的SQL參考

Attack_on_Jager發表於2021-08-04

實驗環境

搭建平臺:VMware Workstation

OS:RHEL 6.10

Grid&DB:Oracle 11.2.0.4


SQL參考

select c.sql_text, a.sql_id, b.object_name, d.mb

  from v$sql_plan a,

       (select *

          from (select sql_id,

                       child_number,

                       object_owner,

                       object_name,

                       parent_id,

                       operation,

                       options,

                       row_number() over(partition by sql_id, child_number, parent_id order by id) rn

                  from v$sql_plan)

         where rn = 2) b,

       v$sql c,

       (select owner, segment_name, sum(bytes / 1024 / 1024) mb

          from dba_segments

         group by owner, segment_name) d

 where b.sql_id = c.sql_id

   and b.child_number = c.child_number

   and b.object_owner = 'TEST'  --使用者名稱

   and a.sql_id = b.sql_id

   and a.child_number = b.child_number

   and a.operation like '%NESTED LOOPS%'  --NL迴圈

   and a.id = b.parent_id

   and b.operation = 'TABLE ACCESS'  --全表掃描“ TABLE ACCESS FULL

   and b.options = 'FULL'

   and b.object_owner = d.owner

   and b.object_name = d.segment_name

 order by 4 desc;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69992972/viewspace-2785130/,如需轉載,請註明出處,否則將追究法律責任。

相關文章