12.2.4.3 The DBA_KEEPSIZES view DBA_KEEPSIZES is a view that makes available the size PL/SQL objects will occupy in the shared pool when kept using the DBMS_SHARED_POOL.KEEP procedure..
Trang 1SIZE(K) KEPT NAME
−−−−−− −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− −−−−−−−−−−−−−−
180 SYS.STANDARD (PACKAGE)
78 YES QDBA.Q$CVAR (PACKAGE)
74 SELECT JOB FROM SYS.DBA_JOBS_RUNNING WHERE JOB = :b1
(0F884588,518752523) (CURSOR)
71 YES QDBA.Q$INSTAT (PACKAGE BODY)
62 YES QDBA.Q$BGPROC (PACKAGE BODY)
PL/SQL procedure successfully completed.
SQL> execute dbms_shared_pool.keep('0F884588,518752523','C');
PL/SQL procedure successfully completed.
SQL> execute dbms_shared_pool.sizes(50);
SIZE(K) KEPT NAME
SIZE(K) KEPT NAME
−−−−−− −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− −−−−−−−−−−−−−−
180 SYS.STANDARD (PACKAGE)
78 YES QDBA.Q$CVAR (PACKAGE)
74 YES(1) SELECT JOB FROM SYS.DBA_JOBS_RUNNING WHERE JOB = :b1 (0F884588,518752523) (CURSOR)
71 YES QDBA.Q$INSTAT (PACKAGE BODY)
62 YES QDBA.Q$BGPROC (PACKAGE BODY)
PL/SQL procedure successfully completed.
After the cursor is pinned, the second call to the SIZES procedure indicates this by showing "YES" in the
KEPT output column It is interesting (and somewhat confusing) that such a simple SELECT statement results
in a cursor that uses 74K of shared pool memory
12.2.4.3 The DBA_KEEPSIZES view
DBA_KEEPSIZES is a view that makes available the size PL/SQL objects will occupy in the shared pool
when kept using the DBMS_SHARED_POOL.KEEP procedure This view can be used by the DBA to plan
for shared pool memory requirements of large PL/SQL objects The actual view definition, contained in the
dbmspool.plb file, follows:
CREATE OR REPLACE VIEW DBA_KEEPSIZES
(totsize, owner, name)
AS
SELECT TRUNC((SUM(parsed_size)+SUM(code_size))/1000)
,owner
,name
FROM dba_object_size
WHERE TYPE IN
('PACKAGE','PROCEDURE','FUNCTION','PACKAGE BODY','TRIGGER')
GROUP BY owner, name;
The columns for DBA_KEEPSIZES are defined in the following table
Column Datatype Description
TOTSIZE NUMBER Size in shared pool if object kept (via KEEP)
OWNER VARCHAR2(30) Schema of the stored PL/SQL object
NAME VARCHAR2(30) Name of the stored PL/SQL object
You can query DBA_KEEPSIZES to get an idea of which packages, procedures, and functions are relatively
[Appendix A] What's on the Companion Disk?
Trang 2large, and thus may be good candidates for pinning into the shared pool.
12.1 DBMS_SPACE:
Obtaining Space
Information
13 Job Scheduling in the
Database
Copyright (c) 2000 O'Reilly & Associates All rights reserved.
[Appendix A] What's on the Companion Disk?
Trang 3Chapter 13
573
Trang 413 Job Scheduling in the Database
Contents:
Getting Started with DBMS_ JOB
Job Queue Architecture
Tips on Using DBMS_JOB
DBMS_JOB Examples
The DBMS_JOB package is actually an API into an Oracle subsystem known as the job queue The Oracle
job queue allows for the scheduling and execution of PL/SQL routines (jobs) at predefined times and/or repeated job execution at regular intervals The DBMS_JOB package provides programs for submitting and executing jobs, changing job execution parameters, and removing or temporarily suspending job execution This package is the only interface with the Oracle job queue
DBMS_JOB is used to schedule many different types of tasks that can be performed in PL/SQL and that require regular execution The job queue is used extensively by Oracle replication facilities, and was
originally developed for the purpose of refreshing Oracle snapshots DBMS_JOB is often used by DBAs to schedule regular maintenance activities on databases, typically during periods of low usage by end users It can similarly be used by applications to schedule large batch operations during off hours The job queue can also be used to start up service programs that listen on database pipes and respond to service requests by user sessions
13.1 Getting Started with DBMS_ JOB
The DBMS_JOB package is created when the Oracle database is installed The dbmsjob.sql script (found in
the built−in packages source code directory, as described in Chapter 1, Introduction) contains the source code
for this package's specification This script is called by catproc.sql, which is normally run immediately after
database creation The script creates the public synonym DBMS_JOB for the package and grants EXECUTE privilege on the package to public All Oracle users can reference and make use of this package
There are several data dictionary views that display information about the Oracle job queue These are called
DBA_JOBS, USER_JOBS, and DBA_JOBS_RUNNING, and are created by the script catjobq.sql This script
is also located in the built−in packages source code directory and is automatically run by catproc.sql.
Finally, the job queue must have its dedicated background processes started in order to operate properly This
is accomplished by setting an initialization parameter in the INIT.ORA file for the database The parameter is,
JOB_QUEUE_PROCESSES = n
where n is a number between 1 and 36 Other INIT.ORA parameters that affect job queue behavior are
discussed in the Section 13.2, "Job Queue Architecture"" section
13.1.1 DBMS_JOB Programs
Table 13.1 lists the programs defined for the DBMS_JOB packages
Table 13.1: DBMS_JOB Programs
SQL?
Trang 5BROKEN Marks the job as broken; do not re−execute No
CHANGE Changes job parameters that can be set by user No
INTERVAL Changes execution interval for job No
ISUBMIT Submits a new job specifying job number No
NEXT_DATE Changes next execution date for job No
REMOVE Removes existing job from the queue No
RUN Runs the job immediately in current session No
SUBMIT Submits a new job obtaining new job number No
USER_EXPORT Creates text of call to recreate a job No
WHAT Changes PL/SQL executed for job No
The DBMS_JOB package does not declare any package exceptions or nonprogram elements In addition, none
of the programs in this package asserts a purity level with the RESTRICT_REFERENCES pragma
13.1.2 Job Definition Parameters
The programs in DBMS_JOB share a set of parameters that define jobs, their execution times, and frequency
of execution All of the DBMS_JOB procedures manipulate one or more of these parameters:
Parameter Description
job Unique identifier of the job
what PL/SQL code to execute as a job
next_date Next execution date of the job
interval Date function to compute next execution date of job
broken Flags job as broken and not to be executed
The following sections describe the characteristics of these parameters that apply to all of the procedures that contain them as formal parameters
13.1.2.1 The job parameter
The job parameter is an integer that uniquely identifies the job It can be either selected by the user or
automatically assigned by the system, depending on which of the two job submission procedures is used to enter the job into the job queue The DBMS_JOB.SUBMIT procedure automatically assigns the job number
by obtaining the next value from the sequence SYS.JOBSEQ It is returned as an OUT parameter so the caller can subsequently identify the job submitted DBMS_JOB.ISUBMIT allows the user to assign a specific integer identifier to the job, and it is up to the caller to ensure that this number is unique
Job numbers cannot be changed other than by removing and resubmitting the job The job number is retained even when the database is exported and imported Be aware of the potential for job number conflicts when performing export/import between databases that contain jobs
13.1.2.2 The what parameter
The what parameter is a character string that evaluates to a valid PL/SQL call to be executed automatically by the job queue You must enclose the what parameter in single quotes if you are using a string literal
Alternatively, you can use a VARCHAR2 variable containing the desired string value The actual PL/SQL call must be terminated with a semicolon To embed literal strings in the PL/SQL call, include two single
[Appendix A] What's on the Companion Disk?