查詢熱點快和熱點塊的操作

kisslfcr發表於2017-09-13
---查詢熱塊物件sql語句:  
SELECT *  
  FROM (SELECT O.OWNER, O.OBJECT_NAME, O.OBJECT_TYPE, SUM(TCH) TOUCHTIME,  
          FROM X$BH B, DBA_OBJECTS O  
         WHERE B.OBJ = O.DATA_OBJECT_ID  
           AND B.TS# > 0  
         GROUP BY O.OWNER, O.OBJECT_NAME, O.OBJECT_TYPE  
         ORDER BY SUM(TCH) DESC)  
 WHERE ROWNUM <= 10   
   
   
--查詢熱點塊操作語句  
 SELECT /*+rule*/  
 HASH_VALUE, SQL_TEXT  
  FROM V$SQLTEXT  
 WHERE (HASH_VALUE, ADDRESS) IN  
       (SELECT A.HASH_VALUE, A.ADDRESS  
          FROM V$SQLTEXT A,  
               (SELECT DISTINCT A.OWNER, A.SEGMENT_NAME, A.SEGMENT_TYPE  
                  FROM DBA_EXTENTS A,  
                       (SELECT DBARFIL, DBABLK  
                          FROM (SELECT DBARFIL, DBABLK  
                                  FROM X$BH  
                                 ORDER BY TCH DESC)  
                         WHERE ROWNUM < 11) B  
                 WHERE A.RELATIVE_FNO = B.DBARFIL  
                   AND A.BLOCK_ID <= B.DBABLK  
                   AND A.BLOCK_ID + A.BLOCKS > B.DBABLK) B  
         WHERE A.SQL_TEXT LIKE '%' || B.SEGMENT_NAME || '%'  
           AND B.SEGMENT_TYPE = 'TABLE')  
 ORDER BY HASH_VALUE, ADDRESS, PIECE;  

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

相關文章