Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event Scheduler in PostgreSQL?

Is there a similar event scheduler from MySQL available in PostgreSQL?

like image 341
Mark Harold C. Rivera Avatar asked Jul 27 '11 04:07

Mark Harold C. Rivera


2 Answers

While a lot of people just use cron, the closest thing to a built-in scheduler is PgAgent. It's a component to the pgAdmin GUI management tool. A good intro to it can be found at Setting up PgAgent and doing scheduled backups.

like image 114
Greg Smith Avatar answered Oct 21 '22 04:10

Greg Smith


pg_cron is a simple, cron-based job scheduler for PostgreSQL that runs inside the database as an extension. A background worker initiates commands according to their schedule by connecting to the local database as the user that scheduled the job.

pg_cron can run multiple jobs in parallel, but it runs at most one instance of a job at a time. If a second run is supposed to start before the first one finishes, then the second run is queued and started as soon as the first run completes. This ensures that jobs run exactly as many times as scheduled and don’t run concurrently with themselves.

If you set up pg_cron on a hot standby, then it will start running the cron jobs, which are stored in a table and thus replicated to the hot standby, as soon as the server is promoted. This means your periodic jobs automatically fail over with your PostgreSQL server.

Source: citusdata.com

like image 26
Fares Younis Avatar answered Oct 21 '22 04:10

Fares Younis