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;
相关推荐
中草药z29 分钟前
【Spring】深入解析 Spring 原理:Bean 的多方面剖析(源码阅读)
java·数据库·spring boot·spring·bean·源码阅读
地球资源数据云30 分钟前
全国30米分辨率逐年植被覆盖度(FVC)数据集
大数据·运维·服务器·数据库·均值算法
Ahern_1 小时前
Oracle 普通表至分区表的分区交换
大数据·数据库·sql·oracle
夜半被帅醒1 小时前
MySQL 数据库优化详解【Java数据库调优】
java·数据库·mysql
不爱学习的啊Biao2 小时前
【13】MySQL如何选择合适的索引?
android·数据库·mysql
破 风2 小时前
SpringBoot 集成 MongoDB
数据库·mongodb
Rverdoser2 小时前
MySQL-MVCC(多版本并发控制)
数据库·mysql
m0_748233642 小时前
SQL数组常用函数记录(Map篇)
java·数据库·sql
dowhileprogramming2 小时前
Python 中的迭代器
linux·数据库·python
0zxm3 小时前
08 Django - Django媒体文件&静态文件&文件上传
数据库·后端·python·django·sqlite