SupabasePaul CopplestoneTutorial
Postgres as a CRON Server
Summary
Postgres databases can schedule and execute external webhook calls periodically by combining the pg_cron and pgsql-http extensions. When configured, pg_cron schedules recurring tasks using standard cron syntax directly inside the database engine. In conjunction, the pgsql-http extension dispatches HTTP requests such as GET, POST, PATCH, and DELETE to external endpoints within SQL queries. Because pg_cron relies on background workers that start one process per server loop iteration, scheduled jobs do not interfere with core postmaster tasks or external client connections. Administrators can monitor job status, review execution logs, and unschedule active tasks directly through dedicated cron schema tables and helper functions.
Context
A Supabase user needed to trigger webhooks periodically before Supabase released its Functions feature, prompting an investigation into whether standard Postgres could manage scheduled external HTTP requests.
Approach / What changed
Enable the pg_cron and pgsql-http extensions in Postgres, grant cron schema permissions to non-superuser roles, and schedule periodic queries containing http_post calls with cron.schedule.
Takeaways
Non-superuser roles require explicit USAGE on schema cron and privileges on its underlying tables, or scheduled jobs will fail to run.
pg_cron executes tasks via background workers that start one process per ServerLoop iteration, preventing slow HTTP requests from blocking core postmaster connection handling.
Cron jobs and execution histories can be inspected using cron.job and cron.job_run_details, and active tasks can be cancelled using cron.unschedule.
Source and freshness
- Source
- supabase.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.