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;
相关推荐
NineData9 小时前
NineData 亮相香港国际创科展 InnoEX 2026,以 AI 加速布局全球市场
运维·数据库·人工智能·ninedata·新闻资讯·玖章算术
m0_377618239 小时前
Redis怎样应对大规模集群的重启风暴_分批次重启节点并等待集群状态恢复绿灯后再继续操作
jvm·数据库·python
imuliuliang10 小时前
存储过程(SQL)
android·数据库·sql
考虑考虑10 小时前
SQL语句中的order by可能造成时间重复
数据库·后端·mysql
2401_8359568110 小时前
Golang怎么写基准测试benchmark_Golang基准测试教程【完整】
jvm·数据库·python
阿杰学AI11 小时前
AI核心知识129—大语言模型之 向量数据库(简洁且通俗易懂版)
数据库·人工智能·ai·语言模型·自然语言处理·向量数据库·vector database
SPC的存折11 小时前
D在 Alpine 容器中手动搭建 Discuz 全攻略(包含镜像一键部署脚本,可直接用)
linux·数据库·mysql·缓存
李兆龙的博客11 小时前
从一到无穷大 #67 大查询根因分析 - 从 PinSQL 到 RCRank
数据库·时序数据库
AgCl2311 小时前
MYSQL-6-函数与约束-3/17
android·数据库·mysql
junqiduhang11 小时前
Win11 MySQL 8.0 安装八步走
数据库·mysql