Tuesday, August 17, 2021

Pin a query in shared pool

 

                                                 pin a query in shared pool

Pinning database objects in Oracle's shared pool can improve database performance. It is recommended that all ESRI stored procedures and sequences be pinned. Once objects reside in Oracle's shared pool, they do not need to be parsed, which saves considerable resources.

Pinning objects in the shared pool uses available memory that might otherwise be used for other processes that share the pool. Allocate the additional memory to the shared pool as needed. In general, do not pin objects that are rarely used; this could have the adverse affect on database performance.

Procedure

1.      Before pinning database objects, create the SYS package that pins the objects in the shared pool. As the SYS user in SQL*Plus, execute the dbmspool.sql script located under the $ORACLE_HOME/rdbms/admin directory.

Optionally, it is possible to grant execute privileges to the new DBMS_SHARED_POOL package to users who will need to pin objects. For example, to grant these privileges to the SDE user:

Code:
GRANT execute ON dbms_shared_pool TO sde;

2.      Begin pinning objects in the shared pool.

Code:
EXECUTE dbms_shared_pool.keep ('STANDARD', 'P'); As a general rule, always pin the following
packages owned by SYS:
   STANDARD
   DBMS_STANDARD
   DBMS_UTILITY
   DBMS_DESCRIBE
   DBMS_OUTPUT
Pinning other SYS packages that are often used, such as DBMS_LOCK and DBMS_ALERT,
may be desired.

3.      As the SDE user, pin the objects that the application frequently uses.
Code:
EXECUTE dbms_shared_pool.keep ('VERSION_UTIL', 'P');

Code:
 EXECUTE dbms_shared_pool.keep ('LOCK_UTIL', 'P');

Database objects are not limited to stored procedures. Database sequences, triggers, and cursors
 can all be pinned in the shared pool. ESRI recommends pinning frequently used sequences as well.
Code:
EXECUTE dbms_shared_pool.keep ('SDE.CONNECTION_ID_GENERATOR', 'Q');

SQL> SELECT 'Example TEST' FROM dual;

'EXAMPLETEST

------------

Example TEST

SQL> select substr(sql_text,1,15) Text,address,hash_value,KEPT_VERSIONS

from v$sql where sql_text like '%Example%';  2 

SQL> @?/rdbms/admin/dbmspool.sql

Session altered.

Package created.

Grant succeeded.

Session altered.

SQL> exec DBMS_SHARED_POOL.PURGE ('000000006189AC28,2929179549','c');

PL/SQL procedure successfully completed.

SQL> select sid,serial#,prev_sql_id from v$session where audsid=userenv('sessionid');

       SID    SERIAL# PREV_SQL_ID

---------- ---------- -------------

            79        57117 5rsr6qt29hu5s

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_Id='5rsr6qt29hu5s';

ADDRESS      HASH_VALUE

---------------- ----------

0000000061A2DE58 1150838968

No comments:

Post a Comment

Oracle OS Management Hub in OCI – A Complete Overview

  Oracle OS Management Hub in OCI – A Complete Overview In any enterprise IT landscape, managing operating systems across hundreds of compu...