Skip to content

How do I clean up older data from the database? #12047

Answered by alangenfeld
alangenfeld asked this question in Q&A
Discussion options

You must be logged in to vote

One option is to use the python APIs against the DagsterInstance to query for older runs and delete them. This is a destructive operation that will remove the events, tags, and run record from the database. This will remove dagster s understanding that this run ever occurred, which can be particularly impactful to partitioned jobs and assets.

Perform this operation with great care.

An example script would look something like this.

import datetime

from dagster import DagsterInstance, RunsFilter

instance = DagsterInstance.get()

# define the time threshold for what is old enough, this example uses 1 week
week_ago = datetime.datetime.now() - datetime.timedelta(days=7)

old_run_records = in…

Replies: 5 comments 10 replies

Comment options

You must be logged in to vote
5 replies
@nsanor
Comment options

@alangenfeld
Comment options

@Lukashab
Comment options

@prha
Comment options

@NiallRees
Comment options

Answer selected by alangenfeld
Comment options

You must be logged in to vote
1 reply
@alangenfeld
Comment options

Comment options

You must be logged in to vote
3 replies
@prha
Comment options

@AndreaGiardini
Comment options

@prha
Comment options

Comment options

You must be logged in to vote
1 reply
@cleboo
Comment options

Comment options

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