Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CREATE SCHEDULE

The scheduler persists schedule definitions and executes SQL actions. The runtime also has a generic path for native actions supplied by providers and extensions.

CREATE SCHEDULE purge_sessions
  EVERY '5 minutes'
  FROM '2026-11-06 23:00:00-03:00'
  DO SQL $$
    DELETE FROM sessions WHERE expires_at < now()
  $$
  WITH (
    overlap = 'skip',
    catch_up = 'none',
    timeout = '1 minute'
  );

EVERY is anchored at FROM; the next occurrence is calculated from that instant, not from the end of the previous execution. A one-time execution uses AT:

CREATE SCHEDULE migrate_legacy
  AT '2026-12-01 02:00:00-03:00'
  DO SQL $$ INSERT INTO new_events SELECT * FROM legacy_events $$;

A materialized view can be refreshed through the same SQL execution path:

CREATE SCHEDULE refresh_dashboard
  EVERY '10 minutes'
  DO SQL $$ REFRESH MATERIALIZED VIEW dashboard $$;

Available policies are overlap = skip|queue|allow, catch_up = none|one, timeout, and max_retries.