Job Priorities
When several jobs within the same job class are
scheduled to start at the same time, the job
coordinator
uses the job priority to decide which job to
execute first.
In the following example, a job is
created and its
job_priority
attribute is set to one using the
set_attribute
procedure.
BEGIN
DBMS_SCHEDULER.create_job (
job_name
=> 'test_priority_job',
job_type
=> 'PLSQL_BLOCK',
job_action
=> 'BEGIN DBMS_LOCK.sleep(10); END;',
start_date
=> SYSTIMESTAMP,
repeat_interval => 'freq=minutely;',
end_date
=> SYSTIMESTAMP + 1/48,
enabled
=> FALSE,
comments
=> 'Job used to test priorities.');
DBMS_SCHEDULER.set_attribute (
name
=> 'test_priority_job',
attribute => 'job_priority',
value
=> 1);
DBMS_SCHEDULER.enable (name => 'test_priority_job');
END;
/
The attribute can be set to any value in the
range from one to five, in which one is the
highest priority.
If a priority is not specified during the
job creation, it is assigned the default value
of three.
The priority of a job can be displayed using the
dba_scheduler_jobs
view, as shown by the following query:
select
job_name,
job_priority
from
dba_scheduler_jobs
order by
job_priority
;
JOB_NAME
JOB_PRIORITY
------------------------------
------------
TEST_PRIORITY_JOB
1
GATHER_STATS_JOB
3
PURGE_LOG
3
This introduction to priorities illustrates that
assigning a priority to jobs within a job class
is easy.
The next section will present information
on scheduler logging that is available as part
of the Oracle scheduler.
Scheduler Logging
The Oracle scheduler logs a number of events
including job maintenance, job run activity and
window activity.
It also gives some degree of control over
the level of logging performed by the scheduler.
The
log_history
scheduler attribute can be used to control the
volume of historical logging information.
However, if a specific job or job class
has a different history requirement, the
set_attribute
procedure
can be used to override this value.
BEGIN
--
Alter log history for a specific job.
DBMS_SCHEDULER.set_attribute (
name
=> 'test_job',
attribute => 'log_history',
value
=> 30);
-- Alter log history for a specific
job class.
DBMS_SCHEDULER.set_attribute (
name
=> 'test_job_class',
attribute => 'log_history',
value
=> 90);
END;
/
There are several types of scheduler logs which
can be managed separately.
In the following sections, information
will be presented on each type of logging
available, starting with job logs.
 |
Fo r more details on Oracle utilities, see the book "Advanced
Oracle Utilities" by Bert Scalzo, Donald K. Burleson, and Steve Callan.
You can buy it direct from the publisher for 30% off directly from
Rampant TechPress.
|