Sunday, August 16, 2015

Oracle : Script shows objects that were read by a full table scan

select /*+ RULE CURSOR_SHARING_EXACT */
  to_char(count(1),'999,999') "BLOCKS",
  substrb(ds.buffer_pool,1,8) "POOL",
  substrb(u.name,1,10) "OWNER",
  substrb(o.name,1,30) "OBJ_NAME",
  decode(o.type#,1,'IND',2,'TAB','OTH') "TYP",
  substr(ds.tablespace_name,1,15) "TS_NAME"
from obj$ o,x$bh x, user$ u, dba_objects dbo, dba_segments ds
where x.obj = o.obj#
--and o.type# = 2
and bitand(x.flag,524288) > 0
and o.owner# = u.user#
and u.name <> 'SYS'
and o.obj# = dbo.object_id
and dbo.owner = ds.owner
and dbo.object_name = ds.segment_name
and dbo.object_type = ds.segment_type
having count(*) > 5
group by u.name, o.name, o.type#, ds.tablespace_name, ds.buffer_pool
order by 1 desc
/

No comments:

Post a Comment