Académique Documents
Professionnel Documents
Culture Documents
Topics
Common issues related to library cache Wait Events Lib Cache Latch/lock mechanism Init.ora parameters effecting lib cache
ii) USE BIND VARIABLES One of the best things that can be done to reduce the amount of fragmentation is to reduce or eliminate the number of sql statements in the shared pool that are duplicates of each other except for a constant that is embedded in the statement. iii) MAX BIND SIZE It is possible for a SQL statement to not be shared because the max bind variable lengths of the bind variables in the statement do not match. iv) ELIMINATING LARGE ANONYMOUS PL/SQL Large anonymous PL/SQL blocks should be turned into small anonymous PL/SQL blocks that call packaged functions. v) REDUCING USAGE
SQL
select sum(sharable_mem) from v$sqlarea;
Limiting Parsing
Types of Parsing
Soft Parse: Syntax + Semantics check only Hard Parse: Syntax +Semantics +optimize, generate the plan for the query
Limiting Parsing
Use Bind variables Use session_cache_cursor Use cursor_sharing=force Avoid using sql, pl.sql blocks inside loop Limiting no. of parse by using bind variables cursor_space_for_time parameter # # Cursor space for time is an optimization which essentially # results in holding pins on cursors and their associated # frames/buffers for longer periods of time. The pins are held # until the cursor is closed, instead of at the end-of-fetch # (normal behavior). This reduces library cache pin traffic # which reduces library cache latch gets. Cursor space for time # is useful for large Applications environments whereby library # cache latch contention, specifically due to pin gets, is an # issue in terms of performance.
Diff Between Lib Cahce Latch and Lib Cache Pin Latch
Library cache latch: The library cache latches protect the cached SQL statements and objects definitions held in the library cache within the shared pool. The library cache latch must be acquired in order to add a new statement to the library cache. During a parse, Oracle searches the library cache for a matching statement. If one is not found, then Oracle will parse the SQL statement, obtain the library cache latch and insert the new SQL. The first resource to reduce contention on this latch is to ensure that the application is reusing as much as possible SQL statement representation. Use bind variables whenever possible in the application. Misses on this latch may also be a sign that the application is parsing SQL at a high rate and may be suffering from too much parse CPU overhead.If the application is already tuned the SHARED_POOL_SIZE can be increased. Be aware that if the application is not using the library cache appropriately, the contention might be worse with a larger structure to be handled. The _KGL_LATCH_COUNT parameter controls the number of library cache latches. The default value should be adequate, but if contention for the library cache latch cant be resolved, it may be advisable to increase this value. The default value for _KGL_LATCH_COUNT is the next prime number after CPU_COUNT. This value cannot exceed 66 (See: <Bbug 1381824>). Library cache pin latch: The library cache pin latch must be acquired when a statement in the library cache is reexecuted. Misses on this latch occur when there is very high rates SQL execution. There is little that can be done to reduce the load on the library cache pin latch, although using private rather than public synonyms or direct object references such as OWNER.TABLE may help
OPEN_CURSORS specifies the maximum number of open cursors (handles to private SQL areas) a session can have at once. You can use this parameter to prevent a session from opening an excessive number of cursors. It is important to set the value of OPEN_CURSORS high enough to prevent your application from running out of open cursors. The number will vary from one application to another. Assuming that a session does not open the number of cursors specified by OPEN_CURSORS, there is no added overhead to setting this value higher than actually needed. To see how many open cursors you have, type:
select * from v$sysstat where name = 'opened cursors current';