-1

我已经为每秒运行的 ORACLE DB 编写了这个计划作业。

现在在我的日程安排程序中,我想做的是将频率设置为每 5 毫秒。

BEGIN    
    sys.dbms_scheduler.create_schedule( 
            repeat_interval =>'FREQ=SECONDLY;INTERVAL=1',
            start_date => to_date('15:19 09/16/10','HH24:MI MM/DD/YY'),
            comments => 'Schedule for periodic loads',
            schedule_name => 'UserName.DOLOADS');   
END;

等待您的宝贵建议..

4

2 回答 2

2

You cannot schedule a DBMS_SCHEDULER (or DBMS_JOB) job to run every 5 milliseconds. Even when you schedule it to run every second, that's only an approximation-- it wouldn't be unexpected if there were 2 or 3 seconds between consecutive runs just because of normal delays between when a job is eligible to be run and the job scheduler actually picks it up and starts running it.

Why would you want a job that your comments describe as a "periodic load" to run every 5 milliseconds? Can you describe the data flow a bit? If you are looking for something like near real-time data replication, there are almost certainly better ways to approach the problem.

All that being said, if you really want to poll very rapidly, the closest you can probably get is to write a job that runs an infinite loop that does a dbms_lock.sleep of 10 milliseconds (0.01 seconds). This will introduce all sorts of additional complexity when you have to do maintenance or shut down the database and have to kill the currently running process, etc. But if schema_name.DoLoads were rewritten to do something like

CREATE PROCEDURE NewDoLoads
AS    
BEGIN
  WHILE( true )
  LOOP
    schema_name.DoLoads;
    dbms_lock.sleep( 0.01 );
  END LOOP;
END NewDoLoads;

that would run the current DoLoads process every 0.01 seconds (10 milliseconds) give or take. That's the smallest increment dbms_lock can handle.

于 2010-09-16T15:05:55.137 回答
2

“这里一秒钟,那里一秒钟,很快你就开始谈论实时了。”

你能更详细地解释一下你想要达到的目标吗?从您的问题中不清楚您是否只想让计划作业每 5 毫秒运行一次,或者您是否希望计划作业本身将其频率从 1 秒更改为 5 毫秒。

我不知道是否可以指定 5ms 的频率,这听起来像是你真的不应该做的事情。

也许研究另一种机制?在我需要近乎即时的作业执行的一种情况下,我使用高级队列快速响应事件并与主要逻辑流并行。

于 2010-09-16T13:59:16.837 回答