Skip to content

Trigger delete for old instances? #174

Closed Answered by wesleykendall
bgervan asked this question in Q&A
Discussion options

You must be logged in to vote

Short answer is no - triggers are driven by events on the table, so this problem doesn't map very well.

You could make a statement-level trigger on your table for any event, cleaning up old rows. This would impact performance whenever there is clean-up to do. Your data would remain uncleaned until there were events on the table.

I would recommend a task scheduler here. If you want to keep all of this in Postgres and not something like Celery, you could consider the pgcron extension, which is supported by AWS and many other DB hosts

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wesleykendall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants