Saturday, June 23, 2012

Find sessions consuming high memory


Find sessions consuming high memory

SELECT  ss.SID,se.status,
        se.command,
        ss.VALUE CPU,
        se.username,
        se.program,
      se.module,
se.SQL_HASH_VALUE,
        se.logon_time
FROM v$sesstat ss, v$session se
WHERE ss.statistic# IN
(SELECT statistic#
FROM v$statname
WHERE NAME = 'session uga memory') AND se.SID=ss.SID AND ss.SID>6 AND se.username IS  NOT NULL AND se.username<>'SYS'
ORDER BY 4 DESC


Regards
Manoj

Database locks In Detail


Database locks in Detail

Create a blocking lock

To begin, create a situation where one user is actively blocking another. Open two sessions. Issue the following commands in Session 1 to build the test table:

SQL> create table tstlock (foo varchar2(1), bar varchar2(1));

Table created.

SQL> insert into tstlock values (1,'a');

1 row created.

SQL> insert into tstlock values (2, 'b');

1 row created.

SQL> select * from tstlock ;

FOO BAR
--- ---
1   a
2   b

2 rows selected.

SQL> commit ;

Commit complete.

Now grab a lock on the whole table, still in Session 1:

SQL> select * from tstlock for update ;

And in Session 2, try to update a row:

SQL> update tstlock set bar=
  2  'a' where bar='a' ;

This statement will hang, blocked by the lock that Session 1 is holding on the entire table.

Identify the blocking session

Oracle provides a view, DBA_BLOCKERS, which lists the SIDs of all blocking sessions. But this view is often, in my experience, a good bit slower than simply querying V$LOCK, and it doesn't offer any information beyond the SIDs of any sessions that are blocking other sessions. The V$LOCK view is faster to query, makes it easy to identify the blocking session, and has a lot more information.

SQL> select * from v$lock ;

ADDR     KADDR           SID TY        ID1        ID2      LMODE    REQUEST      CTIME      BLOCK
-------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
AF9E2C4C AF9E2C60        479 TX     131078      16739          0          6        685          0
ADDF7EC8 ADDF7EE0        422 TM      88519          0          3          0        697          0
ADDF7F74 ADDF7F8C        479 TM      88519          0          3          0        685          0
ADEBEA20 ADEBEB3C        422 TX     131078      16739          6          0        697          1
....     ....            ... ...      ....       ....       ....       ....        ....      ....

Note the BLOCK column. If a session holds a lock that's blocking another session, BLOCK=1. Further, you can tell which session is being blocked by comparing the values in ID1 and ID2. The blocked session will have the same values in ID1 and ID2 as the blocking session, and, since it is requesting a lock it's unable to get, it will have REQUEST > 0.

In the query above, we can see that SID 422 is blocking SID 479. SID 422 corresponds to Session 1 in our example, and SID 479 is our blocked Session 2.

To avoid having to stare at the table and cross-compare ID1's and ID2's, put this in a query:

SQL> select l1.sid, ' IS BLOCKING ', l2.sid
  2  from v$lock l1, v$lock l2
  3  where l1.block =1 and l2.request > 0
  4  and l1.id1=l2.id1
  5  and l1.id2=l2.id2
SQL> /

       SID 'ISBLOCKING'         SID
---------- ------------- ----------
       422  IS BLOCKING         479

1 row selected.

Even better, if we throw a little v$session into the mix, the results are highly readable:

SQL> select s1.username || '@' || s1.machine
  2  || ' ( SID=' || s1.sid || ' )  is blocking '
  3  || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
  4  from v$lock l1, v$session s1, v$lock l2, v$session s2
  5  where s1.sid=l1.sid and s2.sid=l2.sid
  6  and l1.BLOCK=1 and l2.request > 0
  7  and l1.id1 = l2.id1
  8  and l2.id2 = l2.id2 ;


BLOCKING_STATUS
----------------------------------------------------------------------------------------------------
BULKLOAD@yttrium ( SID=422 )  is blocking BULKLOAD@yttrium ( SID=479 )

1 row selected.

There's still more information in the v$lock table, but in order to read that information, we need to understand a bit more about lock types and the cryptically-named ID1 and ID2 columns.

Lock type and the ID1 / ID2 columns

In this case, we already know that the blocking lock is an exclusive DML lock, since we're the ones who issued the locking statement. But most of the time, you won't be so lucky. Fortunately, you can read this information from the v$lock table with little effort.

The first place to look is the TYPE column. There are dozens of lock types, but the vast majority are system types. System locks are normally only held for a very brief amount of time, and it's not generally helpful to try to tune your library cache, undo logs, etc. by looking in v$lock! (See the V$LOCK chapter in the Oracle Database Reference for a list of system lock types.)

There are only three types of user locks, TX, TM and UL. UL is a user-defined lock -- a lock defined with the DBMS_LOCK package. The TX lock is a row transaction lock; it's acquired once for every transaction that changes data, no matter how many objects you change in that transaction. The ID1 and ID2 columns point to the rollback segment and transaction table entries for that transaction.

The TM lock is a DML lock. It's acquired once for each object that's being changed. The ID1 column identifies the object being modified.

Lock Modes

You can see more information on TM and TX locks just by looking at the lock modes. The LMODE and REQUEST columns both use the same numbering for lock modes, in order of increasing exclusivity: from 0 for no lock, to 6 for exclusive lock. A session must obtain an exclusive TX lock in order to change data; LMODE will be 6. If it can't obtain an exclusive lock because some of the rows it wants to change are locked by another session, then it will request a TX in exclusive mode; LMODE will be 0 since it does not have the lock, and REQUEST will be 6. You can see this interaction in the rows we selected earlier from v$lock:

ADDR     KADDR           SID TY        ID1        ID2      LMODE    REQUEST      CTIME      BLOCK
-------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
AF9E2C4C AF9E2C60        479 TX     131078      16739          0          6        685          0
ADEBEA20 ADEBEB3C        422 TX     131078      16739          6          0        697          1

Note that ID1 and ID2 in Session 2, which is requesting the TX lock (LMODE=0, REQUEST=6), point back to the rollback and transaction entries for Session 1. That's what lets us determine the blocking session for Session 2.

You may also see TX locks in mode 4, Shared mode. If a block containing rows to be changed doesn't have any interested transaction list (ITL) entries left, then the session acquires a TX lock in mode 4 while waiting for an ITL entry. If you see contention for TX-4 locks on an object, you probably need to increase INITRANS for the object.

TM locks are generally requested and acquired in modes 3, aka Shared-Row Exclusive, and 6. DDL requires a TM Exclusive lock. (Note that CREATE TABLE doesn't require a TM lock -- it doesn't need to lock any objects, because the object in question doesn't exist yet!) DML requires a Shared-Row Exclusive lock. So, in the rows we selected earlier from v$lock, you can see from the TM locking levels that these are DML locks:

ADDR     KADDR           SID TY        ID1        ID2      LMODE    REQUEST      CTIME      BLOCK
-------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
ADDF7EC8 ADDF7EE0        422 TM      88519          0          3          0        697          0
ADDF7F74 ADDF7F8C        479 TM      88519          0          3          0        685          0

Identifying the locked object

Now that we know that each TM row points to a locked object, we can use ID1 to identify the object.

SQL> select object_name from dba_objects where object_id=88519 ;

OBJECT_NAME
--------------
TSTLOCK

Sometimes just knowing the object is enough information; but we can dig even deeper. We can identify not just the object, but the block and even the row in the block that Session 2 is waiting on.

Identifying the locked row

We can get this information from v$session by looking at the v$session entry for the blocked session:

SQL> select row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#
  2* from v$session where sid=479 ;

ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
------------- -------------- --------------- -------------
        88519             16          171309             0

This gives us the object ID, the relative file number, the block in the datafile, and the row in the block that the session is waiting on. If that list of data sounds familiar, it's because those are the four components of an extended ROWID. We can build the row's actual extended ROWID from these components using the DBMS_ROWID package. The ROWID_CREATE function takes these arguments and returns the ROWID:

SQL> select do.object_name,
  2  row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#,
  3  dbms_rowid.rowid_create ( 1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# )
  4  from v$session s, dba_objects do
  5  where sid=543
  6  and s.ROW_WAIT_OBJ# = do.OBJECT_ID ;

OBJECT_NAME     ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW# DBMS_ROWID.ROWID_C
--------------- ------------- -------------- --------------- ------------- ------------------
TSTLOCK                 88519             16          171309             0 AAAVnHAAQAAAp0tAAA

And, of course, this lets us inspect the row directly.

SQL> select * from tstlock where rowid='AAAVnHAAQAAAp0tAAA' ;

FOO BAR
--- ---
1   a

Conclusion

We've seen how to identify a blocking session, and how to inspect the very row that the waiting session is waiting for. And, I hope, learned a bit about v$lock in the process.

About the author
Source: http://toolkit.rdbms-insight.com/ .

Regards
Manoj

All About Oracle Database Latches


All About Latches

1. What are Oracle latches?
Latches are Oracle-internal low-level locks that protect the memory structures of the system global area (SGA) against simultaneous accesses. Depending on the memory range, there is either a single parent latch or several child latches that each protect subareas of the memory.

2. How does latch allocation work?
There are two different methods for requesting a latch: "Willing to Wait" and "Immediate", where most latch requests are based on "Willing to Wait":

Willing to Wait mode

  •  If a latch is currently in use, the system checks repeatedly in a loop whether the latch has become available ("spinning"). CPU is used in this loop. At the same time, there are NO active Wait events (not even "latch free" events). The number of loops is defined by the internal _SPIN_COUNT Oracle parameter. If only one CPU is available on the system, this step is skipped. Spinning is useful because, in general, latches are only held for a very short time and the request can be fulfilled quickly. In this case, spinning can prevent a context switch, which also consumes a large amount of resources.
  •  If the latch could not be allocated during the entire loop, the process assumes a "sleep" status for a certain period of time. This period is 0.01 seconds for the first sleep. During this sleep, the "latch free" wait event is activated. As of Oracle 10g "important" latches have to be specified in the form "latch: <latch_name>" whereas the less relevant latches will still be logged as "latch free".
  •  The two steps above are repeated until the latch is allocated successfully. The sleep time doubles with every second program run. The maximum sleep time is 2 seconds if another latch is not held, or 0.04 seconds if the process already holds another latch. 


Immediate mode

 
If the requested latch is already in use, the system immediately tries all the other child latches. If none of the child latches can be allocated, the system switches to Willing to Wait mode. 

3. How can I access latch information on the Oracle system?
The following V$ views contain latch information:

V$LATCH: Provides an overview of the latch waits since the system was started.


  •     NAME: The name of the latch.
  •     GETS: The number of "Willing to Wait" requests.
  •     MISSES: The number of "Willing to Wait" requests that could not allocate the latch in the first attempt.
  •     SPIN_GETS: The number of "Willing to Wait" requests that could allocate the latch in the first spinning without sleep periods.
  •     SLEEPS: The number of "Willing to Wait" requests where the process has entered a sleep period at least once.
  •     SLEEP1: The number of "Willing to Wait" requests with exactly one sleep.
  •     SLEEP2: The number of "Willing to Wait" requests with exactly two sleeps.
  •     SLEEP3: The number of "Willing to Wait" requests with exactly three sleeps.
  •     SLEEP4: The number of "Willing to Wait" requests with four or more sleeps.
  •     IMMEDIATE_GETS: The number of "Immediate" requests.
  •     IMMEDIATE_MISSES: The number of "Immediate" requests where the latch could not be allocated on the first attempt.
  •     WAIT_TIME: The combined sleep times of the latch (as of Oracle 9i). 

V$LATCHHOLDER: Provides an overview over the currently held latches.

  •    PID     : Oracle PID <opid> of the process that holds the latch.
  •    SID: Oracle SID of the session that holds the latch.
  •    NAME: The name of the held latch. 

V$LATCHNAME: Provides an overview of the names of all latches.

  •    LATCH#: The number of the latch.
  •    NAME: The name of the latch. 

V$LATCH_MISSES: The number of sleeps and immediate misses, including the Oracle kernel area.


  •    NWFAIL_COUNT: The number of immediate misses.
  •     SLEEP_COUNT: The number of sleeps.
  •     LOCATION: The Oracle kernel area that holds the requested latch. 


V$LATCH_PARENT: Provides an overview of parent latch waits since the system was started.

    This contains the same fields as V$LATCH.

V$LATCH_CHILDREN: Provides an overview of child latch waits since the system was started.

  •    CHILD#: The number of the child latch.
  •     All other fields are the same as in V$LATCH. 


4. How can I access latch information on the R/3 system?
Note the fundamentals for the Oracle performance analysis contained in Note 618868.

5. How I can recognize latch problems?
A latch problem usually exists when there are long "latch free" wait times. Therefore if, when you analyze the wait events in accordance with Note 619188,

you notice that either the entire system or individual transactions are impaired by "latch free" or "latch: <latch_name>" waits, it is worthwhile analyzing and optimizing the latch waits.

6. How can I determine the latches for which the system is currently waiting?
Use the following command to determine which sessions are currently waiting for which latch:

SELECT
   W.SID,
   L.NAME
FROM
   V$SESSION_WAIT W,
   V$LATCHNAME L
WHERE
   W.EVENT LIKE 'latch%' AND
   W.P2 = L.LATCH# AND
   W.STATE = 'WAITING';

7. How can I determine the current latch holders?
Note 20071 describes how you can use the V$LATCHHOLDER view or the BLOCKING_SESSION column from V$SESSION (Oracle 10g or higher) to determine the current

latch holder.

8. How can I determine the most critical latches?
The most critical latches can be determined based on the time spent waiting fr a latch. This information is contained in the WAIT_TIME column of the V$LATCH view. Use the following statement to retrieve the ten latches with the longest wait times since the system was started:

SELECT * FROM (SELECT NAME, WAIT_TIME FROM V$LATCH
ORDER BY WAIT_TIME DESC) WHERE ROWNUM <= 10;

The WAIT_TIME column is only available in Oracle versions after Oracle 8i. In earlier versions, you must use the SLEEPS column for this purpose.It is only useful to determine and tune the most critical latches if an actual latch problem exists. It is completely normal that certain latches such as "shared pool" or "library cache" have significant wait times and are listed at the top of the list.

9. How can I determine objects that are linked to latch waits?
As of Oracle 10g, the V$ACTIVE_SESSION_HISTORY view provides information about the last active wait situations and the affected objects. See Note 619188 for further information. Frequently, latch waits are the essential concurrency waits. Therefore, candidates for latch problems as of Oracle 10g can be determined using the following 

query:

SELECT * FROM
(SELECT
     ROUND(CONCURRENCY_WAIT_TIME / 1000000)
       "CONCURRENCY WAIT TIME (S)",
     EXECUTIONS
     SQL_ID,
     SQL_TEXT
   FROM
     V$SQLSTATS
   ORDER BY CONCURRENCY_WAIT_TIME DESC )
WHERE ROWNUM <=10;

10. What are the general reasons and possible solutions for long latch wait times?
The following are typical reasons for long latch wait times:

Very high access rates to certain memory resources
Reduce the load of these resources depending on the latch wait times that occur as described below.


CPU bottleneck

A CPU bottleneck on the database server may cause extremely long latch waits if processes that hold critical latches are pushed out of the CPU (context switch). In addition, a CPU bottleneck is intensified by the spinning process. Therefore, you should check at operating system level, or by using transactions ST06 or OS07, that there is no CPU bottleneck on the database server (see the CPU guidelines described in Note 618868).

Large-scale parallel processing

On R/3, if an action is parallel-processed too intensively and a lot of processes therefore access the same memory area at the same time, latch waits are very likely. The spinning causes the processes waiting for a latch to consume a lot of CPU memory, which means that the processes that have the latch are pushed from the CPU more quickly. As a result, the latch is kept longer than necessary and the situation deteriorates. Therefore check whether reducing the parallel processing of processes with similar database accesses would reduce the latch waits and improve performance.

Oracle bugs

           Some Oracle bugs may cause long latch wait times. Some of the bugs of which we are aware are listed below in the tuning tips for actual latch waits. However, it is always useful to check for other possible bugs in each case.

Interrupted network connection

           Read Note 20071 and ensure that the latch problem is not caused by an interrupted network connection.

Events and underscore parameters

           In individual cases, Oracle events or underscore parameters may be responsible for increased latch times. For example, setting the 10501 event may cause massive problems due to "shared pool" latches.

           Therefore, check whether there are settings that are not recommended by SAP or are no longer required with the database release that you use, and

remove these.

Oversized shared pool

  In some cases, an oversized shared pool can cause latch wait situations on the shared pool (for example, "library cache" or "row cache objects" latch) since the Oracle-internal administrative structure can by overloaded by the amount of simultaneously retained information. Check whether the configuration of the shared pool is significantly larger than Note 789011 recommends. If this is the case, you should consider a reduction of the SHARED_POOL_SIZE. As a quick solution you can use

ALTER SYSTEM FLUSH SHARED_POOL;

Paging

Increased paging may also lead to latch problems. If a process has allocated a latch, and must retrieve the relevant memory area from the disk, it may take longer until the latch is released again. Therefore, latch wait situations are more likely.

HP-UX: Process scheduling

When you use HP-UX, critical latch situations may be made worse by the default process scheduling mechanism, if processes in critical sections (in other words, with a held latch) are displaced from the CPU. In this case, you can reconsider using the HPUX_SCHED_NOAGE Oracle parameter in accordance with 

metalink document 217990.1 to reduce these displacements.

Error ORA-04031:

In individual cases, ORA-04031 error situations can lead to increased latch waits. Therefore, check if ORA-04031 errors were logged in critical latch periods, and see Note 869006 if this is the case.

11. How can I tune actual latch waits?
Depending on which latch the system is waiting for, you have the following options:

library cache / library cache pin

           Wait event > = 10g: "latch: library cache" / "latch: library cache pin"

Wait situations on the "library cache" latch and "library cache pin" latch usually occur in the SAP environment, if you execute a large number of identical SQL statements in parallel (with relation to bind variables). Therefore, avoid the parallel execution of a large number of similar SQL statements that only differ in the content of their bind variables. To determine which SQL statements are responsible for the latch problems, first determine the child latches:

SELECT NAME, CHILD#, WAIT_TIME
FROM V$LATCH_CHILDREN
WHERE NAME LIKE 'library cache%'
ORDER BY WAIT_TIME DESC;

           You can then start a query on V$SQL for the child latches that have the longest waiting period:

SELECT * FROM
( SELECT EXECUTIONS, PARSE_CALLS, ADDRESS, SQL_TEXT
   FROM V$SQL
   WHERE CHILD_LATCH = <child#>
   ORDER BY EXECUTIONS DESC )
WHERE ROWNUM <=10;

The system returns the 10 SQL statements that are protected by the child latch specified, and that are executed most frequently. In certain cases it may be recommended to increased the number of latches using the Oracle parameter _KGL_LATCH_COUNT. Depending on this parameter, the number of library cache" latches, "library cache pin" latches and "library cache pin allocation" latches is determined using the following 

formula:

#Latches = MIN(67, next_larger_prime_number(_KGL_LATCH_COUNT))

As a last solution, you may consider using SQL statements that have similar meaning but are different from a parse point of view (for example, by specifying a different comment or pseudo hint). By this, the load is distributed more evenly on different child latches. Wait situations for the "library cache" latch occur if the system must parse a large number of SQL statements. Therefore, you should check the 

following points:


  •     Check, as described in Note 618868, whether the shared pool size is sufficient.
  •     Avoid the large-scale use of REPARSE or SUBSTITUTE VALUES hints according to Note 129385, as these hints mean that significantly more statements must  be parsed.
  •    The creation of statistics, shared pool flushes and DDL statements (for example, TRUNCATE) also require additional parsing of statements. Therefore, 


you should also check to what extent these actions occur on a large scale.

shared pool

           Wait event >= 10g: "latch: shared pool"
           Refer to the information about the "library cache" latch above.

cache buffers chains

           Wait event >= 10g: "latch: cache buffer chains"
           "Cache buffers chains" latch waits are usually caused by hot blocks, that is, blocks that are accessed frequently. Hot blocks can be identified as  follows:

Execute the following statement repeatedly to determine which "cache buffers chains" child latch is responsible for the highest number of sleeps:

      SELECT
      *
      FROM
      (SELECT
      CHILD#,
      ADDR,
      WAIT_TIME
      FROM
      V$LATCH_CHILDREN
      WHERE
      NAME = 'cache buffers chains'
      ORDER BY
      WAIT_TIME DESC)
      WHERE
      ROWNUM < 10;


Now execute the following query for X$BH with the ADDR value of the most expensive child latch to determine which blocks protected by the child latch 

have the highest touchcount:

      SELECT /*+ RULE */
      SUBSTR(E.OWNER, 1, 15) OWNER,
      SUBSTR(E.SEGMENT_NAME, 1, 20) SEGMENT_NAME,
      X.FILE# "FILE",
      X.DBABLK "BLOCK",
      DECODE(X.DBABLK - BLOCK_ID + EXTENT_ID, 0, 'YES', 'NO') HEADER,
      SUM(X.TCH) "TOUCHCOUNT"
      FROM V$LATCH_CHILDREN L, X$BH X, DBA_EXTENTS E
      WHERE X.HLADDR = '<addr>' AND
      E.FILE_ID = X.FILE# AND
      X.HLADDR = L.ADDR AND
      X.DBABLK BETWEEN
      E.BLOCK_ID AND E.BLOCK_ID + E.BLOCKS - 1
      GROUP BY E.OWNER, E.SEGMENT_NAME, X.FILE#, X.DBABLK,
      DECODE(X.DBABLK - BLOCK_ID + EXTENT_ID, 0, 'YES', 'NO'),
      X.TCH
      ORDER BY SUM(X.TCH) ASC;
   
The touchcount is only a rough measurement for using individual blocks - even if a block is used repeatedly within a very short time, the touchcount is only increased once. Nevertheless, combined with the executed SQL statements, it may be a useful indication of the trigger of "cache buffers chains" latches.

By optimizing the accesses to the relevant objects, you can also reduce the number of "cache buffers chains" latches. On Oracle 8.1. 7, the "cache buffers chains" latches may be triggered by the Oracle bugs described in Notes 449136 and 488583. The number of "cache buffers chains" latches depends on the size of the buffer pool and can be approximated using the following formula:

#Latches =
   Next largest power of 2 (Size of the buffer pool/1048576).

The exact calculation formula depends on the use of DB_BLOCK_BUFFERS vs. DB_CACHE_SIZE, since block header information is also stored in the  granules when DB_CACHE_SIZE is used. Also, the size of the granules is important for DB_CACHE_SIZE. The following default values should in any case return 

the larger number of latches:

    * Buffer Pool < 1124073472 Byte -> 1024 Latches
    * Buffer Pool >= 1124073472 Byte -> 2048 Latches
    * Buffer Pool >= 2231369728 Byte -> 4096 Latches
    * Buffer Pool >= 4445962240 Byte -> 8192 Latches
    * Buffer Pool >= 8875147264 Byte -> 16384 Latches
    * Buffer Pool >= 17733517312 Byte -> 32768 Latches
    * Buffer Pool >= 35500000000 Byte -> 65536 Latches

If you have problems with "cache buffers chains" latches, and have defined an Oracle buffer pool just below one of the threshold values described above and have enough memory available to increase the size of the buffer pool, it may be useful to increase the buffer pool size to the next threshold value.

Alternatively, you can use the _DB_BLOCK_HASH_LATCHES parameter to define the number of "cache buffers chains" latches. However, you should only explicitly set this parameter in individual cases that warrant this setting.  If "cache buffers chains" latches occur in Oracle 10.2.0. 2, see Note 1020225.

cache buffers lru chain

         Wait event >= 10g: "latch: cache buffers lru chain"
          They are usually triggered by expensive SQL statements. Perform an SQL optimization as described in Note 766349.

 In addition, check whether the DBWR performs poorly when you save dirty blocks (for example, using a wait event analysis as described in Note 619188). You should also ensure that the Oracle buffer pool size is sufficient (see the information in Note 618868). Alternatively, you can use the _DB_BLOCK_LRU_LATCHES parameter to adjust the number of "cache buffers lru chain" latches. However, you should only explicitly set this parameter in individual cases that warrant this setting.

cache buffer handles

           Wait event >= 10g: "latch: cache buffer handles"

In Oracle 8.1. 7, the bug described in Note 400698 may be responsible for serializations of the "cache buffer handles" latch. enqueue hash chains

           Wait event >= 10g: "latch: enqueue hash chains"

If wait times for "enqueue hash chains" latches occur together with deadlock dumps, see Note 596420 and ensure that bottlenecks do not occur when dump files are created (I/O, mount options of the file system, and so on). archive control Wait situations on the "archive control" latch are generally a follow-on problem of archiver stuck situations. You should therefore check whether an archiver stuck situation has occurred, as described in Note 391.

undo global data

The "undo global data" latch is required for accessing undo data. Increased waiting imes on this latch are usually due to expensive SQL statements that access consistent read images due to the data in the undo segments. In this case, optimize the expensive SQL statements and make sure that there is no large number of open changes (also see Note 913247). 

query server process

The "query server process" latch is retained if new slaves are generated during parallel execution. Refer to the corresponding information in Note 651060.

simulator lru latch

Significant wait times for the "simulator lru latch" are often a result of processing-intensive SQL statements that execute a large number of buffer gets. Therefore, you must first check if these accesses exist and whether they can be optimized. Long waiting times for the "simulator lru latch" may also occur when you create fixed object statistics using DBMS_STATS.GATHER_FIXED_OBJECTS_STATS (or "brconnect -f oradict_stats"). This affects mainly systems with a large buffer pool, as in these cases, the table X$KCBSH becomes quite large. Therefore, the statistics creation on this table takes a long time. During the statistics creations, problems with the "simulator lru latch" may occur.

As a workaround, you can set the parameter  DB_CACHE_ADVICE to OFF, which means that the LRU simulation is deactivated in the buffer pool. Note that if you perform this task, you can no longer collect data in V$DB_CACHE_ADVICE (Note 617416).

12. Will latch deadlocks occur?
Generally, the Oracle implementation ensures that no latch deadlocks can occur. However, in the case of bugs, deadlocks may occur. In this case, the transaction terminates with ORA-00600 [504]. If you encounter this error and you cannot find a suitable note, you should create a customer message.

13. Where can I find more information about latches?
Oracle documentation:

Oracle9i Performance Tuning Guide and Reference
22 Instance Tuning
-> Wait Events
-> latch free

Oracle 9i Reference
-> Dynamic Performance Views
-> V$LATCH

Oracle 10g Performance Tuning Guide and Reference
10 Instance Tuning Using Performance Views
-> Wait Events Statistics

Oracle 10g Reference
-> 4 Dynamic Performance Views
-> V$LATCH


Regards
Manoj

Tuesday, June 5, 2012

Gather stats for PeopleSoft application database

Gather stats for PeopleSoft application database

BEGIN
DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS('SYSADM',DBMS_STATS.AUTO_SAMPLE_SIZE);
END;

Regards
Manoj

Delete archive logs of all instances running on the machine

one line command to delete archive log older than  10 days for all instance currently running on the machine.

This is useful on machines that run non-production instance and there is no specific naming convention for the SID's. 

ps -ef | grep ora_pmon | grep -v grep | awk '{print $8}' | awk '{gsub(/ora_pmon_/,"export ORACLE_SID=");}1' | grep -v awk | awk '{print $0,"; echo \"delete noprompt archivelog until time \x27 sysdate - 7 \x27 ;\" | rman target /;";} > del_arch.sh ; sh del_arch.sh




Regards
Manoj

Monday, December 26, 2011

Move Datafiles on standby server without moving Primary


Move Datafiles on standby server without moving Primary
Include below parameter in standby parameter file
DB_FILE_NAME_CONVERT = '/primary_location/xyz.dbf','/standby_location/xyz.dbf'
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
shut immediate
startup nomount pfile=initSCSL.ora
alter database mount standby database ;
alter system set standby_file_management='MANUAL' SCOPE=MEMORY ;
! cp /primary_location/xyz.dbf'  /standby_location/xyz.dbf
alter database rename file  '/primary_location/xyz.dbf' to '/standby_location/xyz.dbf';
alter system set standby_file_management='AUTO' SCOPE=MEMORY ;
alter database recover managed standby database parallel 4 disconnect from session;

OR
-concept not tested--do a test on non-produciton-
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
mv  /primary_location/xyz.dbf  /standby_location/xyz.dbf
create a soft link ln -s /standby_location/xyz.dbf /primary_location/xyz.dbf
startup nomount pfile=initSCSL.ora
alter database mount standby database ;
alter database recover managed standby database parallel 4 disconnect from session;

Regards
Manoj

Thursday, October 20, 2011

XXX Is not a valid responsibility for the current user

There are multiple fixes for the error, some are listed below

This error is displayed because of the caching framework of apache, workflow components in oracle apps are suppose to sync the cache. When workflow events fail to trigger/function due to some XYZ reason, this issue occurs. Make sure workflow components are working optimally for permanent fix for temporary fix clear cache.

1. Clear cache
Go to > Functional Administrator responsibility
Click on Core services tab (the tab at the top right)
Click on Caching Framework Tab (blue tab under main tab)
Click on Global configuration
Click on Clear All Cache
A warning message related to performance will come , say yes

2. Bounce Apache by clearing cache
 
 
Regards
Manoj

Wednesday, October 12, 2011


Datafile high water mark
How lower can you resize datafiles ?
define blksize=8192 –set  your db block size

select /*+rule*/ 'alter database datafile '''||file_name||''' resize '||ceil( (nvl(hwm,1)*&blksize)/1024/1024)||'m;',
ceil( (nvl(hwm,1)*&blksize)/1024/1024 ) smallest,
ceil( blocks*&blksize/1024/1024) currsize,
ceil( blocks*&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&blksize)/1024/1024 ) savings
from
   dba_data_files a,
   (select file_id, max(block_id+blocks-1) hwm
   from
      dba_extents
   group by file_id ) b
where a.file_id = b.file_id(+);


source: dba-oracle.com

Regards
Manoj

Thursday, September 29, 2011

Check India Localization patchset level
How to check the current India Localization Patchset Level installed on an Instance


India Localization Patchset is IN60107(Patch Number = 5498551)
If the Patch Number 5498551 is applied, your current India Localization patchset is IN60107.
This can be verified by running the below select
select * from JAI_APPLIED_PATCHES where Patch_number = 5498551;

If the Patch Number 5498551 is not applied, the India Localization Patchset should be IN60106 or below.
This can be checked by running the below statement:-
select * from JA_IN_INSTALL_CHECK_INFO where name like '601%';


source: Metalink ID: 752704.1

Regards
Manoj

Monday, September 5, 2011

select Query to view long running sql's

select Query to view long running sql's

set linesize 160
set pagesize 100

col machine for a15

select
machine,
ELAPSED_SECONDS,
TIME_REMAINING,
100 - (TIME_REMAINING*100/ELAPSED_SECONDS),
OPNAME  ,
b.TARGET,
b.sid
from
v$session a,
v$session_longops b
where a.sid=b.sid and
time_remaining != 0 ;

Thursday, August 18, 2011

Compiling forms in Oracle apps (e-business suite) 11i

Compiling forms in Oracle apps (e-business suite) 11i

All module fmb are located in $AU_TOP
-Change directory to $AU_TOP/forms/US
Take backup of existing fmx

f60gen module=<formname>.fmb userid=apps/<apps_pwd> output_file=<required_module_top>/forms/US/<formname>.fmx

Regards
Manoj

Oracle E-business suite logs clean up

 Oracle E-business suite logs clean up #!/bin/bash cd $EBS_DOMAIN_HOME find $EBS_DOMAIN_HOME -type f -path "*/logs/*.log?*" -mtime...