oracle latch锁,请问latch有哪些用途,它和lock的区别是什么?

lock是锁定数据库中的对象的  latch(锁存)进行操作的对象是数据库内部加锁

当事务需向缓冲区写入信息时,为了使用此块内存区域, ORACLE首先必须取得这块内存区域的锁存,才能向此块内存写入信息。

相关文档如下:

Latches are different from locks (enqueues) in several ways, although both are locking mechanisms.

Latches vs. Locks

Purpose

Serve a single purpose: to provide exclusive access to memory structures. (Starting in Oracle9i Database, the cache buffers chains latches are shareable for read-only.)

Serve two purposes: to allow multiple processes to share the same resource when the lock modes are compatible and to enforce exclusive access to the resource when the lock modes are incompatible.

Jurisdiction

Apply only to data structures in the SGA.

Protect memory objects, which are temporary.

Control access to a memory structure for a single operation.

Not transactional.

Protect database objects such as tables, data blocks, and state objects.

Application driven and control access to data or metadata in the database.

Transactional.

Acquisition

Can be requested in two modes: willing-to-wait or no-wait.

Can be requested in six different modes: null, row share, row exclusive, share, share row exclusive, or exclusive.

Scope

Information is kept in the memory and is only visible to the local instance—latches operate at instance level.

Information is kept in the database and is visible to all instances accessing the database—locks operate at database-level.

Complexity

Implemented using simple instructions, typically, test-and-set, compare-and-swap, or simple CPU instructions. Implementation is port specific because the CPU instructions are machine dependent.

Lightweight.

Implemented using a series of instructions with context switches.

Heavyweight.

Duration

Held briefly (in microseconds).

Normally held for an extended period of time (transactional duration).

Queue

When a process goes to sleep after failing to acquire a latch, its request is not queued and serviced in order (with a few exceptions—for example, the latch wait list latch has a queue). Latches are fair game and up for grabs.

When a process fails to get a lock, its request is queued and serviced in order, unless the NOWAIT option is specified.

Deadlock

Latches are implemented in such a way that they are not subject to deadlocks.

Locks support queuing and are subject to deadlocks. A trace file is generated each time a deadlock occurs.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值