Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The difference between Latch and Lock

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Latch is a lightweight lock resource provided by Oracle, which is used to lock resources quickly and for a short time, to prevent multiple concurrent processes from modifying to access a shared resource at the same time, he only works in memory, we can not say exactly, the lock of resources in memory is called latch, and the lock of database objects (tables, indexes, etc.) is called Lock. For example, if a block in the data cache is to be read, we will get the latch of this block. This process is called pin. Another process happens to modify this block, and he also wants to pin this block. At this time, he must wait for the current process to release latch before it can pin live, and then modify it. If multiple processes request at the same time, there will be competition between them, without a queue mechanism, once the previous process releases the set. There is no concept of "first come, first come". This is essentially different from Lock. It all happens very quickly, because the characteristic of Latch is fast and short. Of course, this is only a general process. The details will first look at the difference between Latch and Lock. 1. Latch is a mechanism that provides mutually exclusive access to in-memory data structures. While Lock acquires shared resource objects in different modes, and there are compatibility or exclusion among various modes. From this point, Latch access, including queries, is also mutually exclusive. At any time, only one process can pin a certain piece of memory. Fortunately, this process is quite short, otherwise there will be no guarantee of system performance. Starting from 9i, many processes are allowed to query the same memory block at the same time. But the performance is not as good as expected. 2. Latch only acts in memory and can only be accessed by the current instance, while Lock acts on database objects and allows Lock detection and access between instances in the RAC system. Latch is an instant occupation and release, and the release of Lock needs to wait until the transaction ends correctly, and the time it takes is determined by the transaction size. 4. Latch is not queued, while Lock is queued. Latch does not have deadlocks. It exists in Lock (deadlocks are very rare in Oracle)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report