all AI news
Making PostgreSQL tick: New features in pg_cron
Simon Willison's Weblog simonwillison.net
Making PostgreSQL tick: New features in pg_cron
pg_cron adds cron-style scheduling directly to PostgreSQL. It's a pretty mature extension at this point, and recently gained the ability to schedule repeating tasks at intervals as low as every 1s.
The examples in this post are really informative. I like this example, which cleans up the ever-growing cron.job_run_details table by using pg_cron itself to run the cleanup:
SELECT cron.schedule('delete-job-run-details', '0 12 * * *', $$DELETE FROM cron.job_run_details WHERE end_time < now() - …
cron every example examples extension features low making new features postgresql scheduling sql tasks