ITPUB论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
更多
查看: 7539|回复: 25

[精华] 请问library cache pin和library cache lock是latch吗 [复制链接]

精华贴数
1
技术积分
133
社区积分
0
注册时间
2008-5-6
论坛徽章:
0
发表于 2008-6-20 20:09:34 |显示全部楼层
请问library cache pin和library cache lock是latch吗?对这个问题一直很模糊!

版主

月是上弦

精华贴数
7
技术积分
3624
社区积分
161
注册时间
2008-2-15
论坛徽章:
26
2010新春纪念徽章
日期:2010-01-04 08:33:08现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-02-18 11:42:472011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:41:012010新春纪念徽章
日期:2010-03-01 11:04:582010新春纪念徽章
日期:2010-01-04 11:01:512010新春纪念徽章
日期:2010-01-04 11:00:552010新春纪念徽章
日期:2010-01-04 11:00:32
发表于 2008-6-20 21:27:23 |显示全部楼层
不是,Library cache pin是Oracle内部针对共享池的内存块的一种锁。
一些内存块合在一起存贮了一种对象。比如游标,一般需要两个两个内存块,一个存贮一般信息,另一个存贮执行执行计划。需要有一个总的内存块来管理这些分散的内存块,一般称这个总的内存块为句柄。Library cache lock是针对这个句柄块的锁。
全面提供OCP,OCM认证,ORACLE 第三方技术服务

OCP&OCM认证  考试五群 58614576
OCP&OCM认证  考试六群 107062685
OCP&OCM认证  考试七群 65058302
长春 Oracle Club 群 123275956

提供11G OCP认证服务
OCP&OCM认证  考试一群 101435(已满)
OCP&OCM认证  考试二群 22090594(已满)
OCP&OCM认证  考试三群 10317220(已满)
OCP&OCM认证  考试四群 41511680(已满)
<b><font color="blue">


为了方便大家查阅,所有的文章都已转入空间

http://www.dba168.com/

请大家多多支持!

使用道具 举报

精华贴数
1
技术积分
133
社区积分
0
注册时间
2008-5-6
论坛徽章:
0
发表于 2008-6-21 10:04:51 |显示全部楼层
感谢晶晶的回答,这个我知道,但是这些都是内存锁,难道latch不是锁内存的吗?

使用道具 举报

版主

月是上弦

精华贴数
7
技术积分
3624
社区积分
161
注册时间
2008-2-15
论坛徽章:
26
2010新春纪念徽章
日期:2010-01-04 08:33:08现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-02-18 11:42:472011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:41:012010新春纪念徽章
日期:2010-03-01 11:04:582010新春纪念徽章
日期:2010-01-04 11:01:512010新春纪念徽章
日期:2010-01-04 11:00:552010新春纪念徽章
日期:2010-01-04 11:00:32
发表于 2008-6-21 12:30:18 |显示全部楼层
Library cache Lock/Pin和Latch都是锁,只不过它们的实现方式不一样。相比之下,大多数的Latch只是内存中的一些字节,通过在这些字节中设置某个值,代表Latch所保护的对象是否被占用,大部分闩没有等待者队列、占用者队列等队列,等等吧。Latch的工作方式和Library cache Lock/Pin不太一样。它们都是锁,只不过有些是暗锁,有些是明锁,就是这样吧,实现方式不同,因此就说锁的类型不同。

[ 本帖最后由 晶晶小妹 于 2008-6-21 12:32 编辑 ]
全面提供OCP,OCM认证,ORACLE 第三方技术服务

OCP&OCM认证  考试五群 58614576
OCP&OCM认证  考试六群 107062685
OCP&OCM认证  考试七群 65058302
长春 Oracle Club 群 123275956

提供11G OCP认证服务
OCP&OCM认证  考试一群 101435(已满)
OCP&OCM认证  考试二群 22090594(已满)
OCP&OCM认证  考试三群 10317220(已满)
OCP&OCM认证  考试四群 41511680(已满)
<b><font color="blue">


为了方便大家查阅,所有的文章都已转入空间

http://www.dba168.com/

请大家多多支持!

使用道具 举报

版主

版主

精华贴数
3
技术积分
9663
社区积分
196
注册时间
2001-10-9
论坛徽章:
23
ITPUB元老
日期:2005-02-28 12:57:002011新春纪念徽章
日期:2011-01-25 15:41:012011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-02-18 11:43:33ITPUB年度最佳技术回答奖
日期:2011-04-08 18:37:39现任管理团队成员
日期:2011-05-07 01:45:08ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412011新春纪念徽章
日期:2011-01-04 10:24:02ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
发表于 2008-6-22 03:18:19 |显示全部楼层
chandler_1983's question can also be looked at this way: What do the latches "library cache pin" and "library
cache lock" do and what's the difference between "latch free" wait event where the latches are these two
types and the "library cache pin" or "library cache lock" waits themselves? Do the numbers
v$latch.gets for library cache lock/pin or the numbers v$system_event.total_waits for them tell us
the actual number of library cache locks/pins we've had in the database since instance startup?

If you check v$latch for these two latches and compare with the same name wait events in
v$system_event, you'll see the two latches are get'ed much more frequently. I think the numbers
for the two latches in v$latch accurately reflect the actual pins/locks we've had. There's no
statistic in v$sysstat or v$sesstat for latch gets, probably because v$latch.gets serves the
purpose already. If the database is not too busy causing waits on them, the numbers in
v$system_event (or other wait related views) will not increment. In fact, v$latch.sleeps should be
equal to these latches' "latch free" waits because latch waits are the same as latch sleeps. You
can test on a quiet single-user database, with no jobs or scheduler jobs, and very quickly type
select name, gets, misses, sleeps, immediate_gets from v$latch where name in ('library cache pin',
'library cache lock'). You'll see the pin gets keep going up (by 2 in my 10.2.0.1 database) while
lock gets stay the same. The 2 pins must be due to this SQL itself. Values in v$system_event stay
the same.

Yong Huang

[ 本帖最后由 Yong Huang 于 2008-6-23 06:07 编辑 ]

使用道具 举报

注册会员

Oracle,Db2,MQ

精华贴数
0
技术积分
2878
社区积分
87
注册时间
2006-11-25
论坛徽章:
21
祖国60周年纪念徽章
日期:2009-10-09 08:28:00ITPUB元老
日期:2009-12-20 10:42:092010年世界杯参赛球队:巴西
日期:2010-06-15 20:33:58ITPUB十周年纪念徽章
日期:2011-11-01 16:23:26
发表于 2008-6-23 15:36:07 |显示全部楼层
恩,学习一下

使用道具 举报

版主

月是上弦

精华贴数
7
技术积分
3624
社区积分
161
注册时间
2008-2-15
论坛徽章:
26
2010新春纪念徽章
日期:2010-01-04 08:33:08现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-02-18 11:42:472011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:41:012010新春纪念徽章
日期:2010-03-01 11:04:582010新春纪念徽章
日期:2010-01-04 11:01:512010新春纪念徽章
日期:2010-01-04 11:00:552010新春纪念徽章
日期:2010-01-04 11:00:32
发表于 2008-6-23 17:21:04 |显示全部楼层
library cache pin latch和library cache lock latch好像在文档上看过,因为Library cache Lock/Pin都不是原子操作,因此为了不使在加或释放Library cache Lock/Pin时,有其他操作对它们进行打扰,因为使用Library cache Lock/Pin latch对加、释放Lock/Pin的过程加以保护。
全面提供OCP,OCM认证,ORACLE 第三方技术服务

OCP&OCM认证  考试五群 58614576
OCP&OCM认证  考试六群 107062685
OCP&OCM认证  考试七群 65058302
长春 Oracle Club 群 123275956

提供11G OCP认证服务
OCP&OCM认证  考试一群 101435(已满)
OCP&OCM认证  考试二群 22090594(已满)
OCP&OCM认证  考试三群 10317220(已满)
OCP&OCM认证  考试四群 41511680(已满)
<b><font color="blue">


为了方便大家查阅,所有的文章都已转入空间

http://www.dba168.com/

请大家多多支持!

使用道具 举报

超级版主

人生就是如此

精华贴数
39
技术积分
113462
社区积分
12356
注册时间
2001-12-12
论坛徽章:
73
ITPUB元老
日期:2005-02-28 12:57:00ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41蜘蛛蛋
日期:2011-07-01 08:38:17蛋疼蛋
日期:2011-05-27 08:50:45现任管理团队成员
日期:2011-05-07 01:45:082010广州亚运会纪念徽章:皮划艇
日期:2011-04-26 11:24:14咸鸭蛋
日期:2011-11-09 09:55:402011新春纪念徽章
日期:2011-02-18 11:43:322011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
发表于 2008-6-23 19:21:08 |显示全部楼层
获得一个library cache lock,表示获得到一个 handle,可以是  null、share,exclusive 三种模式。 根据这个handle可以获得到object。

pin 则是表示拥有handle情况下,要真正地使用这些object,必须把这些object 钉在内存中,这也分了 null、share、exclusive三种模式。

所以tom曾经简单描述过:  lock, get a handle,是一个寻找的结果; pin,excute ,使用寻找到的结果


结合sql的执行,编译,ddl的发生等情况可以理解三种模式的可能意义。

至于yong huang的例子中 pin增加  lock不增加,可以看作是 执行次数增加,但是由于session已经获得handle 不需要重新去寻找获得(session已经 cached这个 cursor ,表示已经获得handle)


这时我的理解,有什么不对欢迎讨论。

使用道具 举报

版主

版主

精华贴数
3
技术积分
9663
社区积分
196
注册时间
2001-10-9
论坛徽章:
23
ITPUB元老
日期:2005-02-28 12:57:002011新春纪念徽章
日期:2011-01-25 15:41:012011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-02-18 11:43:33ITPUB年度最佳技术回答奖
日期:2011-04-08 18:37:39现任管理团队成员
日期:2011-05-07 01:45:08ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412011新春纪念徽章
日期:2011-01-04 10:24:02ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
发表于 2008-6-23 20:12:39 |显示全部楼层
I modified my text and specially added these words:

"the numbers [i.e. gets]
for the two latches in v$latch accurately reflect the actual pins/locks we've had. There's no
statistic in v$sysstat or v$sesstat for latch gets, probably because v$latch.gets serves the
purpose already. If the database is not too busy causing waits on them, the numbers in
v$system_event (or other wait related views) will not increment. In fact, v$latch.sleeps should be
equal to these latches' "latch free" waits because latch waits are the same as latch sleeps."

Yong Huang

使用道具 举报

版主

版主

精华贴数
3
技术积分
9663
社区积分
196
注册时间
2001-10-9
论坛徽章:
23
ITPUB元老
日期:2005-02-28 12:57:002011新春纪念徽章
日期:2011-01-25 15:41:012011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-02-18 11:43:33ITPUB年度最佳技术回答奖
日期:2011-04-08 18:37:39现任管理团队成员
日期:2011-05-07 01:45:08ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412011新春纪念徽章
日期:2011-01-04 10:24:02ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
发表于 2008-6-23 20:17:13 |显示全部楼层
原帖由 biti_rainy 于 2008-6-23 05:21 发表
至于yong huang的例子中 pin增加  lock不增加,可以看作是 执行次数增加,但是由于session已经获得handle 不需要重新去寻找获得(session已经 cached这个 cursor ,表示已经获得handle)


Exactly! Can we guess what the 2 pins are for each execution? I type
select name, gets, misses, sleeps, immediate_gets from v$latch where name in ('library cache pin',
'library cache lock')
in quick succession and v$latch.gets for library cache pin goes up by 2. Why 2? One for x$kslld and one for x$ksllt, the two base table under v$latch?

Yong Huang

使用道具 举报

相关内容推荐
您需要登录后才可以回帖 登录 | 注册

TOP技术积分榜 社区积分榜 徽章 电子杂志 团队 统计 邮箱 虎吧 老博客 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档 | IT博客
CopyRight 1999-2011 itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有 联系我们 网站律师 隐私政策 知识产权声明
京ICP证:060528号 北京市公安局海淀分局网监中心备案编号:1101082001 广播电视节目制作经营许可证:编号(京)字第1149号
  
回顶部