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;
相关推荐
广州智造3 小时前
OptiStruct实例:3D实体转子分析
数据库·人工智能·算法·机器学习·数学建模·3d·性能优化
技术宝哥6 小时前
Redis(2):Redis + Lua为什么可以实现原子性
数据库·redis·lua
学地理的小胖砸8 小时前
【Python 操作 MySQL 数据库】
数据库·python·mysql
dddaidai1238 小时前
Redis解析
数据库·redis·缓存
数据库幼崽8 小时前
MySQL 8.0 OCP 1Z0-908 121-130题
数据库·mysql·ocp
Amctwd8 小时前
【SQL】如何在 SQL 中统计结构化字符串的特征频率
数据库·sql
betazhou9 小时前
基于Linux环境实现Oracle goldengate远程抽取MySQL同步数据到MySQL
linux·数据库·mysql·oracle·ogg
lyrhhhhhhhh9 小时前
Spring 框架 JDBC 模板技术详解
java·数据库·spring
喝醉的小喵11 小时前
【mysql】并发 Insert 的死锁问题 第二弹
数据库·后端·mysql·死锁
付出不多11 小时前
Linux——mysql主从复制与读写分离
数据库·mysql