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;
相关推荐
消失的旧时光-194316 分钟前
第五课:数据库不是存数据那么简单 —— MySQL 与索引的后端视角
数据库·mysql
nice_lcj52026 分钟前
MySQL中GROUP_CONCAT函数详解 | 按日期分组拼接销售产品经典案例
数据库·mysql
key1s30 分钟前
在 clickhouse时间降序排序解决方案
数据库
有梦想有行动34 分钟前
ClickHouse的Partition和Part概念
linux·数据库·clickhouse
GZ_TOGOGO39 分钟前
Oracle数据库考试适合哪些人
数据库·oracle·数据库开发·ocp认证·2026年it学习
Gauss松鼠会40 分钟前
【openGauss】学习 gsql 命令行的使用
数据库·sql·database·opengauss
晓13131 小时前
第二章:Redis常见命令与Java客户端
java·数据库·redis
·云扬·1 小时前
MySQL索引实战指南:添加场景、联合索引要点与失效场景解析
数据库·mysql
填满你的记忆1 小时前
【从零开始——Redis 进化日志|Day7】双写一致性难题:数据库与缓存如何不再“打架”?(附 Canal/读写锁实战)
java·数据库·redis·缓存·面试
小白考证进阶中1 小时前
MySQL OCP认证可以考中文?备考难度怎么样?
数据库·mysql·dba·数据库管理·开闭原则·数据库管理员·mysql认证