https://prefect.io logo
Title
s

Sander

05/20/2022, 9:29 AM
Hi, wrt keeping the database size and performance good, is there a way to set some sort of retention rate policy on the database that maintains the flows, flowruns, etc?
1
I'm referring to a Postgres database for 2.0
a

Anna Geller

05/20/2022, 10:53 AM
you may use e.g. pg_cron or something like that to periodically run some DBA tasks such as purging old logs, but be careful about which data you delete, e.g. purging logs should be fine, but purging flow runs you need to be careful to not break other tables that reference that flow run ID btw I thought you are on Cloud 2.0? if so, you don't have to worry at all about DBA tasks and retention policies
🙂 1
s

Sander

05/20/2022, 11:16 AM
I'm running my own Postgres and gui. There are no on delete cascade foreign keys?
Actually. Let me check :)
Looks fine to me actually. Some depend rows are deleted and some are set to null. No doubt there are some bugs here and there, but generally structure looks ok. (Referring to bugs as at some point I ran into the issue where I couldn't reset the database due to foreign key constraints. ) 🙂
a

Anna Geller

05/20/2022, 11:24 AM
yup, FK constraints is exactly what I meant - if not doing it carefully you may cause issues
s

Sander

05/20/2022, 11:26 AM
I guess it somewhere on the roadmap to provide some cleanup scripts to allow proper cleanup of the database?
No need now but wondering
a

Anna Geller

05/20/2022, 11:45 AM
I can open an issue if you want
@Marvin open "Consider adding DB cleanup scripts to save space in Postgres"
👍 1