Timers¶
Timers allow data to be manipulated at consistent time intervals. These intervals can be at specific times, days, dates, or at regular intervals.
CREATE TIMER¶
Overview
This command allows you to add script that will be executed on a periodic basis. A special variable _time
will be available as a local variable to the executing script
timer_name
- name of the timer to create, each timer's name must be unique within the databasepriority
- a number, triggers with lowest value are executed first. Only considered when two or more timers have the same exact scheduled time.-
schedule
- either:
Logging options:
off
(default): no logging.on
: logs the time when the timer is called and when it completes.verbose
: equivalent of using show_plan=ON in AMIDB. Logs the time that a timer starts and finishes and also each query step.
Example¶
In these examples assume we have the tables A(a boolean) and table B(time utc, cnt int). These timers, when executed, will insert a row into table B with the count of records in A.
DROP TIMER¶
Example¶
This example will drop the timer MyTimer from the database
Execution Time¶
The actual timer execution period might differ from the one we specified. Consider the following example. There are two timers that are scheduled to run on 5 second periods but take at least 30 seconds to finish. These two commands query the database from MySQL, and are considered deferred statements, where the timer will wait for the last execution to finish before running the next job.
There are several cases:
- If the timer has a specified timeout, the timer will execute again once the timeout has been reached.
- For the timer with the Cron schedule, the timer will wait until the next valid time to execute.
- In both cases, the timers will either execute every 30 seconds or wait until the previous request finishes executing or has timedout.