1. 程式人生 > >指令碼之找出佔用了Buffer Cache裡大量的buffer的資料庫物件

指令碼之找出佔用了Buffer Cache裡大量的buffer的資料庫物件

找出大量消耗(佔用)了Buffer Cache(裡的buffer的個數)的資料庫物件。下面的語句就可以完成這一工作:
SQL> column c0 heading 'Owner'                     format a15
SQL> column c1 heading 'Object|Name'               format a30
SQL> column c2 heading 'Number|of|Buffers' //該資料庫物件使用了的buffer的個數        format 999,999
SQL> column c3 heading 'Percentage|ofData|Buffer' 
//該資料庫物件使用了的buffer的個數與buffer cache裡總
buffer的個數的百分比    format 999,999,999
SQL> select
  2     owner                        c0,
  3     object_name                  c1,
  4     count(1)                     c2,
  5     (count(1)/(select count(*) from v$bh)) *100  c3
  6  from
  7     dba_objects o,
  8     v$bh        bh
  9  where
 10     o.object_id  = bh.objd
 11  and
 12     o.owner not in ('SYS','SYSTEM')
 13  group by
 14     owner,
 15     object_name
 16  order by
 17     count(1) desc
 18  ;
C0              C1                                     C2         C3
--------------- ------------------------------ ---------- ----------
PLSQLDEV        STANDARD_CITY                  17290      72.5860621
DBOWNER         MSG_LOG                        2          0.00839630
DBOWNER         COUNTRY_PK                     1          0.00419815
DBOWNER         PARAMETER                      1          0.00419815
DBOWNER         PARAMETER_PK                   1          0.00419815
DBOWNER         MSG_LOG_IDX1                   1          0.00419815
6 rows selected
SQL>