Oracle如何定位硬解析高的语句?

==查询subpool 情况

sql 复制代码
select KSMDSIDX supool,round(sum(KSMSSLEN)/1024/1024,2) SQLA_size_mb  
from x$ksmss  
where KSMDSIDX<>0  
and KSMSSNAM='SQLA'  
group by KSMDSIDX;

==查询subpool top5

sql 复制代码
 SELECT *
    FROM (SELECT KSMDSIDX subpool,
                 KSMSSNAM name,
                 ROUND(KSMSSLEN / 1024 / 1024 / 1024, 2) compent_size_gb,
                 ROW_NUMBER() OVER(PARTITION BY KSMDSIDX ORDER BY KSMSSLEN DESC) RANK
            FROM x$ksmss) t
   WHERE t.RANK < 6
     AND subpool > 0
   ORDER BY t.subpool, -t.compent_size_gb;

==监控 size>10m的sql cursor

sql 复制代码
Select sysdate,sql_text,sql_id,sharable_mem from v$sqlarea where sharable_mem > 10000000 order by sharable_mem;

==找硬解析次数大于200的语句

sql 复制代码
With c As
 (Select inst_id,
         force_matching_signature,
         round(Sum(sharable_mem) / 1024 / 1024, 2) shared_mb,
         Max(sql_id) As max_sql_id,
         Count(*) cnt
    From gv$sqlarea
   Where force_matching_signature != 0
   Group By inst_id, force_matching_signature
  Having Count(*) > = 200),
sq As
 (Select inst_id,
         sql_text,
         plan_hash_value,
         force_matching_signature,
         row_number() over(Partition By inst_id, force_matching_signature, plan_hash_value Order By inst_id, sql_id Desc) p
    From gv$sqlarea s
   Where force_matching_signature In
         (Select force_matching_signature From c))
Select Sysdate,
       inst_id,
       max_sql_id               As "sql_id",
       plan_hash_value,
       shared_mb                As "shared mem(MB)",
       force_matching_signature,
       cnt                      As "sql_count",
       rank,
       sql_text
  From (Select c.inst_id,
               sq.sql_text,
               c.max_sql_id,
               sq.plan_hash_value,
               sq.force_matching_signature,
               c.shared_mb,
               c.cnt,
               row_number() over(Partition By c.inst_id Order By c.inst_id, c.shared_mb Desc, c.cnt Desc) rank
          From c, sq
         Where sq.force_matching_signature = c.force_matching_signature
           And sq.inst_id = c.inst_id
           And sq.p = 1
         Order By inst_id, c.shared_mb Desc, c.cnt Desc) t
 Where t.rank <= 20;
相关推荐
Python私教2 小时前
model中能定义字段声明不存储到数据库吗
数据库·oracle
BestandW1shEs5 小时前
谈谈Mysql的常见基础问题
数据库·mysql
重生之Java开发工程师5 小时前
MySQL中的CAST类型转换函数
数据库·sql·mysql
教练、我想打篮球5 小时前
66 mysql 的 表自增长锁
数据库·mysql
Ljw...5 小时前
表的操作(MySQL)
数据库·mysql·表的操作
哥谭居民00015 小时前
MySQL的权限管理机制--授权表
数据库
wqq_9922502775 小时前
ssm旅游推荐系统的设计与开发
数据库·旅游
难以触及的高度5 小时前
mysql中between and怎么用
数据库·mysql
Jacky(易小天)6 小时前
MongoDB比较查询操作符中英对照表及实例详解
数据库·mongodb·typescript·比较操作符