重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3289|回复: 0
打印 上一主题 下一主题

[Oracle] 会导致library cache latch占用高产生的一些原因

[复制链接]
跳转到指定楼层
楼主
发表于 2020-11-6 18:28:02 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
在AWR报告中遇到了latch:library cache占用I/O高的情况,所以去了解了一下引起这参数占用高的原因
The library cache latches protect the cached SQL statements and objects' definitions held in the library cache within the shared pool. The library cache latch must be acquired in order to add a new statement to the library cache. During a parse, Oracle searches the library cache for a matching statement.
If one is not found, then Oracle will parse the SQL statement, obtain the library cache latch and insert the new SQL



library cache latch保护共享池中在library cache缓存的SQL语句和对象定义。
必须获取library cache latch才能在继续添加新的语句缓存。在解析期间,Oracle在缓存中搜索匹配的语句。
如果找不到,那么Oracle将解析SQL语句,获取library cache latch并插入新的SQL。


每一个sql被执行之前,先要到library cache中根据hash_value查找parent cursor,这就需要先获得library cache latch;
找到parent cursor后,就会去查找对应的child cursor,当发现无法找到时,就会释放library cache latch,获得share pool latch分配空间给硬解析后的产生的执行计划;
然后再次获得library cache latch进行把执行计划放入share pool,转入library cache pin+lock(null模式)开始执行sql.library cache latch 的个数有限(与CPU_COUNT参数相关),当数据库中出现大量硬解析的时候,某一个sql无法得到library cache latch就会开始spin,达到spin count后还没得到,就会开始sleep,达到sleep时间后,醒来还再次试图过的library cache latch得不到就在spin再得不到又sleep…依此类推.


根据这样的过程便可以知道:在sql执行的过程中,在出现High Versions Count高版本游标数目多和Hard Parse大量硬解析的情况下都有可能出现library cache latch等待,导致library cache latch占用系统的I/O

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-9-24 02:28 , Processed in 0.083302 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表