Skip to content

Is it possible to do internal transaction control using a stored procedure scheduled with pg_cron? #407

Description

@me-honest

I have a use case where I want to delete expired entries, but since they are heavily connected each might take some time and DELETE CASCADE many records with it. Therefore, to avoid long running transactions, I wanted to commit after each deletion.

I found that it is not possible just using SQL statements, since pg_cron is already running everything inside a transaction. But by testing, I found that stored procedures called from the cron allowed to do it.

I tried verifying with pgadmin and it does look like indeed the stored procedure is commiting the transactions successfully in between the deletions, but I wanted to verify that there were no unintended side effects since this seems to be an "undocumented" area. I suppose a similar case to #85.

Can anybody chime in? I hope this issue also serves as documentation at least, since I searched a lot in the internet and didn't find info about this topic. Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions