Oracle job运行的最短 interval间隔时间是多短?
Oracle job运行的最短 interval间隔时间是多短? 问题不限版本, 欢迎各种答案!如题! job运行完后会更新next time吧。我猜是job运行能多短。间隔就能多短吧。但感觉是不是有隐藏参数控制着啊,还没仔细研究过。 曾经使用过sql developer,在设置job间隔的时候只能设置整数的,也就是1秒~~~,不知道是否正确 OS: RHEL 5.4 64bit
Oracle Version: 10.2.0.4 64bit , 10.2.0.5 64bit
测试得出的结论是5s。
测试过程如下:
测试前,先建立一个t表,表中包含一个timestamp的字段。
然后,写一个存储过程pro_t_insert里面包含insert当前时间到t表里。
testcase:drop table t;
create table t (t timestamp);
drop procedure pro_t_insert;
create procedure pro_t_insert
is
begin
insert into t values(sysdate);
commit;
end;
/
var jid number;
-- 这里设置的job执行间隔为1s
exec dbms_job.submit(:jid,'PRO_T_INSERT;', sysdate, 'sysdate+1/86400');
exec dbms_job.run(:jid);
set serveroutput on;
exec dbms_output.put_line(:jid);
select job, last_date, last_sec, interval, failures, what from all_jobs where job=:jid;正常运行存储过程的时间:SQL> set timing on;
SQL> exec pro_t_insert;
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02从t表看到的结果如下:11-JUN-12 03.26.07.000000 PM
11-JUN-12 03.26.12.000000 PM
11-JUN-12 03.26.17.000000 PM
11-JUN-12 03.26.22.000000 PM
11-JUN-12 03.26.27.000000 PM
11-JUN-12 03.26.32.000000 PM
11-JUN-12 03.26.37.000000 PM
11-JUN-12 03.26.42.000000 PM
11-JUN-12 03.26.47.000000 PM
11-JUN-12 03.26.52.000000 PM
11-JUN-12 03.26.57.000000 PM也就是间隔5s。
不知道还可不可以设置得更短。:) 我这边测试了一下,也是5秒,设置成不足5秒的,都算5秒.
主要是看dba_jobs.last_DATE一次增加5秒
奇怪了,之前设置了60秒,结果是每60+5秒执行一次
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production 8i 版本有个控制这个间隔时间参数
JOB_QUEUE_INTERVAL,这个参数值多少,即为多少
9i 时,这个参数就没了,默认应该就是5秒了
10g引入了SCHEDULER新特性,创建job的DBMS_SCHEDULER.CREATE_JOB方法中有个REPEAT_INTERVAL,根据这个参数设置时间间隔,最小值应该是1s,
即使这个参数设置为 freq=secondly;INTERVAL=0,间隔还是1秒
不知道说得对不,欢迎各位批评指正
哇 ,凑个热闹,来学习学习 好贴
DBMS_JOB 受到参数JOB_QUEUE_INTERVAL的影响 默认最小间隔是5s,可以通过手动设置减少到1s一次, 1s 是最短间隔
SQL> alter system set "_JOB_QUEUE_INTERVAL"=1 scope=spfile;
System altered.
reboot instance !!!
SQL> exec dbms_job.submit(:v_job,what=>'begin insert into ttime values(systimestamp); end;',next_date=>SYSDATE,INTERVAL=>'sysdate+1/86400');
PL/SQL procedure successfully completed.
SQL> exec dbms_job.run(:v_job);
PL/SQL procedure successfully completed.
SQL> /
T1
---------------------------------------------------------------------------
11-JUN-12 08.55.26.096802 AM
11-JUN-12 08.55.27.409266 AM
11-JUN-12 08.55.28.406008 AM
11-JUN-12 08.55.29.409585 AM
11-JUN-12 08.55.30.410420 AM
11-JUN-12 08.55.31.414326 AM
11-JUN-12 08.55.32.416529 AM
11-JUN-12 08.55.33.419503 AM
11-JUN-12 08.55.34.420857 AM
11-JUN-12 08.55.35.428322 AM
11-JUN-12 08.55.36.431015 AM
T1
---------------------------------------------------------------------------
11-JUN-12 08.55.37.430584 AM
11-JUN-12 08.55.38.434955 AM
11-JUN-12 08.55.39.437548 AM
11-JUN-12 08.55.40.439631 AM
11-JUN-12 08.55.41.441646 AM
11-JUN-12 08.55.42.441856 AM
11-JUN-12 08.55.43.446503 AM
11-JUN-12 08.55.44.447652 AM
11-JUN-12 08.55.45.449934 AM
11-JUN-12 08.55.46.451910 AM
DBMS_SCHEDULER
SQL> create table ttime_scheduler(t1 timestamp);
Table created.
SQL> alter system set "_JOB_QUEUE_INTERVAL"=30 scope=spfile;
System altered.
SQL> startup force;
ORACLE instance started.
Total System Global Area 851443712 bytes
Fixed Size 2100040 bytes
Variable Size 738198712 bytes
Database Buffers 104857600 bytes
Redo Buffers 6287360 bytes
Database mounted.
Database opened.
建立每秒运行1次的 scheduler job
SQL> set linesize 140 pagesize 1400
SQL> show parameter job_queue
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
_job_queue_interval integer 30
SQL> exec DBMS_SCHEDULER.CREATE_JOB(JOB_NAME => 'my_report_job',JOB_TYPE => 'PLSQL_BLOCK',JOB_ACTION => 'begin insert_job; end;', START_DATE => SYSDATE,REPEAT_INTERVAL => 'FREQ=SECONDLY; INTERVAL=1;', END_DATE => SYSDATE+30,ENABLED => TRUE);
SQL> select * from ttime_scheduler;
T1
---------------------------------------------------------------------------
11-JUN-12 09.09.38.117732 AM
11-JUN-12 09.09.39.215509 AM
11-JUN-12 09.09.40.309133 AM
11-JUN-12 09.09.41.413390 AM
11-JUN-12 09.09.42.513138 AM
11-JUN-12 09.09.43.609060 AM
11-JUN-12 09.09.44.700273 AM
11-JUN-12 09.09.45.818303 AM
11-JUN-12 09.09.46.909685 AM
11-JUN-12 09.09.48.012584 AM
11-JUN-12 09.09.49.111379 AM
11-JUN-12 09.09.50.208165 AM
11-JUN-12 09.09.51.306311 AM
11-JUN-12 09.09.52.404987 AM
11-JUN-12 09.09.53.512844 AM
11-JUN-12 09.09.54.610366 AM
11-JUN-12 09.09.55.710293 AM
11-JUN-12 09.09.56.814974 AM
11-JUN-12 09.09.57.917172 AM
11-JUN-12 09.09.59.006032 AM
11-JUN-12 09.10.00.108008 AM
11-JUN-12 09.10.01.218745 AM
11-JUN-12 09.10.02.311328 AM
可以看到scheduler 不受_job_queue_interval 参数的影响 此贴加精华 学习了。 刘大这好东西多。。 好论坛中的好贴。希望刘大多做一些专题,让更多的兄弟们扫扫盲。非常感觉! 学习了。 刘大这好东西多。。 学习了
页:
[1]