Running the Heartbeat Update and Purge Function
The heartbeat table and associated functions are created from the ADD
HEARTBEATTABLE
command, however for PostgreSQL, there is no automatic
scheduler to call the functions.
One main function controls both the heartbeat record update and the heartbeat history table purge functions. The default settings for both of these features are 60 seconds for the update frequency and 1 day for the history record purge, which deletes all records older than 30 days by default.
To call the main heartbeat record function, users should create an operating system level
job that executes “select ggschema.gg_hb_job_run();”
. When this
function is called, it will take into account the update frequency settings and history
record purge settings and use those values regardless of the scheduler settings for the
function call.
*****PGPASSWORD="gguserpasswd" psql -U gguser -d dbname -h remotehost -p 5432 -c "select ggschema.gg_hb_job_run();" >/dev/null
2>&1
pgAdmin, or pg_cron are other programs that could be used to schedule the function call.