citusdata / citusdata/pg_cron

How to delay by N seconds

Open
#355 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.9k
Forks
260
Avg merge
5d 5h
Merged PRs (30d)
1

Description

I am invoking a webhook every minute, but it needs to be done on the :55s mark. Below is how I'm currently achieving this with `pg_sleep`. However, the waiting time appears in my logs as slow queries.

Can delay be integrated into pg_cron?

```sql
select
cron.schedule(
'invoke-function-every-minute',
'* * * * *',
$$
select pg_sleep(55);
select
net.http_post(
url:='https://test.requestcatcher.com/api/cron',
headers:='{"Content-Type": "application/json"}'::jsonb,
body:=concat('{"time": "', clock_timestamp(), '"}')::jsonb
) as request_id;
$$
);
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.