DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Latch

  1. #1
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    Hi

    Cany anyone state a definition of Latch with a small example?
    It seems to me like a latch is a block for memory structure as DML locks for data however I cant imagine how do latch protect the memory, in which way. DML lock is much easier to understand, when I update a row then that row is blocked. If this was with latch does it mean when i select some rows from data block buffer the rows i gather will be blocked to others but instead of a lock a latch? Latch is only present in SGA?

    Cheers

  2. #2
    Join Date
    Jul 2000
    Location
    Oxford, OH
    Posts
    117
    From Steve Adam's "Oracle8i Internal Services for
    Waits, Latches, Locks, and Memory"


    "Latches are more restrictive because they do not allow processes to inspect the protected data structure at the same time-they provide for exclusive access only. (redo copy latches can be shared but this is hardware dependent). Locks allow for better concurrency because they may be held in shared mode when the data structure is simply being inspected."

    "Another significant difference between locks and latches is request queuing. Requests for locks are queued if necessary and serviced in order, whereas latches do not support request queuing. If a request to get a latch fails because the latch is busy, the process just continues to retry until it succeeds. So latch requests are not necessarily serviced in order."

    =================

    BTW: This is an excellent book and Steve is a great guy to talk to and is quite an Oracle Guru! He has an excellent website: [url]http://www.ixora.com.au[/url] if you haven't checked it out, do so! He has some great papers, explanations, and advanced performance tuning scripts.

    Joe
    _________________________
    Joe Ramsey
    Senior Database Administrator
    dbaDirect, Inc.
    (877)687-3227

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    i understand this is a good book and I am planning to buy it with several other Oracle books such as

    Oracle 24X7 Tips & Techniques (Oracle Press)
    Scaling Oracle8I(tm): Building Highly Scalable OLTP System Architectures
    Oracle Performance Tuning Tips & Techniques
    Oracle8I Internal Services for Waits, Latches, Locks, and Memory


    hmm i still dont see very clear about latch though

  4. #4
    Join Date
    Jul 2000
    Location
    Oxford, OH
    Posts
    117
    Pando,

    It's a bit late tonight but I'll try to research it a bit more tomorrow and try to give you a clearer idea.

    Joe
    _________________________
    Joe Ramsey
    Senior Database Administrator
    dbaDirect, Inc.
    (877)687-3227

  5. #5
    Join Date
    Jul 2000
    Location
    Oxford, OH
    Posts
    117
    Pando,

    I haven't had a chance to finish my research yet to write up a full explanation. However, one point that might help that I forgot to mention was that locks operate on objects like tables and rows while latches protect internal Oracle structures like the buffer pools.
    _________________________
    Joe Ramsey
    Senior Database Administrator
    dbaDirect, Inc.
    (877)687-3227

  6. #6
    Join Date
    Aug 2000
    Location
    Singapore
    Posts
    323
    Hi all,

    I do have some information on Latch's go through it. Thanks in Advance.
    << Start >>
    Watch that Latch !
    Latch is a low level locking mechanism provided by oracle. In this article we will look at the latch concept and how to tune the server to reduce latch contention.
    What is a Latch ?
    A Latch is a low level serialization mechanism that ( released as quickly as it is acquired ) protects shared data structures. A process acquires and holds the latch as long as the the data structure is in use. The basic idea is to prevent concurrent access to shared data structures in in the SGA. In case the process dies without releasing the latch, the PMON process will clean up the lock on the data structure and releases the latch.
    If a process is not able to obtain a latch, it must wait for the latch to be freed up by process holding it. This causes additional spinning ( looking for availability at fixed intervals of time ) of the process, there by causing extra load on the CPU. This process will spin until the latch is available. A dba has to monitor the latches for contention and make sure that CPU cycles are not being burnt on process spinning.
    The Tunable Trio ( .. 3 latches I monitor )
    You cannot monitor and tune all the available internal latches in oracle. The few latches I monitor are Redo Allocation Latch, Redo Copy Latch and Row Cache objects Latch.
    · Redo Allocation Latch controls the allocation of space for redo entries in the redo log buffer.
    · Redo Copy Latch is used when the size of a redo entry is greater than the value of LOG_SMALL_ENTRY_MAX_SIZE.
    · Row Cache Latch is used when a process attempts to access the data dictionary information from the cache.
    select c.name,a.gets,a.misses,a.sleeps, a.immediate_gets,a.immediate_misses,b.pid
    from v$latch a, v$latchholder b, v$latchname c
    where a.addr = b.laddr(+)
    and a.latch# = c.latch#
    and (c.name like 'redo%' or c.name like 'row%'
    order by a.latch#;
    When you execute the above script, the output will display the name of the latch and various other statistics about the redo and row cache latches. The values of gets, misses and sleeps are willing to wait operations, i.e, the requesting process will wait a short time, if the latch is busy, and request the latch again. The immediate_gets and immediate_misses columns represent the number of successful and unsuccessful immediate requests for the latches.
    To make the database perform well, try to adjust parameters to keep the miss ratio [(misses/gets)*100 ] for each of these latches to a minimum.( < 1 )

    Tuning Process ( What to do If I have Contention )

    In case of redo allocation latch contention, try to decrease the log_small_entry_max_size so that the redo copy latch is used more.

    If the query shows heavy redo copy latch contention, set the value of log_simultaneous_copies to the number of cpu's. If it still does not help and the contention on the allocation latch is low, then try increasing the log_small_entry_max_size to shift some load to the allocation latch.
    In order to decrease the contention on the row cache latch, increase the shared_pool_size since the data dictionary is a part of the shared pool.

    When tuning Oracle, one has to remember that there are no absolute values for tuning and the best balance between the values has to be obtained by incremental tuning.

    << End >>

    Nagesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width