Home » RDBMS Server » Server Administration » Automatic Process for Pinning Packages under WinNT/2K
Automatic Process for Pinning Packages under WinNT/2K [message #52060] Mon, 01 July 2002 01:51 Go to next message
Nagesh
Messages: 18
Registered: April 2002
Junior Member
Hello,

My application requires pinning of packages. Right now i am manually pinning the packages after instance up by using DBMS_SHARED_POOL_KEEP('');
My database environment is Win 2k.

How can i achieve automatic process for pinning packages while instance up instead of manual process.

Thanks in advance.

Nagesh.
Re: Automatic Process for Pinning Packages under WinNT/2K [message #52070 is a reply to message #52060] Mon, 01 July 2002 07:44 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
this may help you. Change the code, where ever you want. this is
customized to our environment.
1. login as SYS.

2. Create a table to store the names of packages that had to be pinned
   let the table name me pin_list

	   SQL> create table sys.pin_list (owner varchar2(64),NAME VARCHAR2(100));

	   Table created.

3. create a procedure proc_Pin_list that gets the packages
   that will be kept in the shared pool at startup and inserts 
   the names in the table.

	SQL> ed
	Wrote file afiedt.buf

	  1  create or replace PROCEDURE proc_pin_list AS
	  2          cursor pkgs is
	  3           select owner,name
	  4             from SYS.v_$db_object_cache
	  5             where type in ('PACKAGE','PROCEDURE')
	  6             and   (loads > 1 or KEPT='YES');
	  7      BEGIN
	  8            delete from sys.pin_list;
	  9            commit;
	 10            for rec in pkgs loop
	 11            exit when pkgs%notfound;
	 12            insert into sys.pin_list values (rec.owner,rec.name);
	 13        commit;
	 14        end loop;
	 15*       end;
	SQL> /

	Procedure created.

c. The procedure proc_Pin_keep KEEPS the packages in shared pool

	SQL> CREATE OR REPLACE PROCEDURE sys.proc_pin_keep AS
	  2   cursor pkgs is
	  3      select owner ,name
	  4     from sys.pin_list;
	  5     BEGIN
	  6      for rec in pkgs loop
	  7      exit when pkgs%notfound;
	  8      SYS.dbms_shared_pool.keep(''||rec.owner || '.' ||rec.name || '');
	  9      end loop;
	 10      sys.dbms_shared_pool.keep('SYS.STANDARD');
	 11      sys.dbms_shared_pool.keep('SYS.DIUTIL');
	 12     END;
	 13  /

	Procedure created.

d. create a triggers to be fired before the instance shuts down
   and after the instance starts up.	
    
	SQL> ed
	Wrote file afiedt.buf

	  1   CREATE OR REPLACE TRIGGER db_shutdown_list
	  2     BEFORE SHUTDOWN ON DATABASE
	  3     BEGIN
	  4       sys.proc_pin_list;
	  5*     END;
	  6  /

	Trigger created.

	SQL> ed
	Wrote file afiedt.buf

	  1   CREATE OR REPLACE TRIGGER db_startup_keep
	  2    AFTER STARTUP ON DATABASE
	  3    BEGIN
	  4    sys.proc_pin_keep;
	  5*   END;
	SQL> /

	Trigger created.
Re: Automatic Process for Pinning Packages under WinNT/2K [message #52089 is a reply to message #52070] Tue, 02 July 2002 06:00 Go to previous messageGo to next message
B
Messages: 327
Registered: August 1999
Senior Member
Whoawwww GOOD IDEA Mahesh. But i think it's work only on Oracle 9+ ( because Trigger AFTER STARTUP or Before SHUTDOWN don't work on ORACLE 8 or less )... Can just use Dynamic SQL like:

spool test.sql
select 'exec DBMS_SHARED_POOL.KEEP('''||object_name||''',''P'')' from all_objects
where ( condition to get the wanted packages, don't forget DBMS_STANDARD and DBMS_SQL );
spool off
@test.sql
Re: Automatic Process for Pinning Packages under WinNT/2K [message #52098 is a reply to message #52089] Tue, 02 July 2002 06:42 Go to previous message
B
Messages: 327
Registered: August 1999
Senior Member
Thanks, i think your really good, you are certified, arent't you ?
Previous Topic: Performance tuning
Next Topic: identify tables used in table scans (long)
Goto Forum:
  


Current Time: Tue Sep 17 20:24:45 CDT 2024