-
Notifications
You must be signed in to change notification settings - Fork 14.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DAG deletion is slow due to lack of database indexes on dag_id #20249
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
Let’s add indexes to those tables then. Would you be interested in looking into those various tables and create one for each of them? |
bit of analysis for this ticket, these are the models which do and dont have indexes on dag id
|
There are composite indexes on some of the tables, I don't think we need explicit index of
|
Apache Airflow version
2.2.1
What happened
We have an airflow instance for approximately 6k DAGs.
Most of the execution time appears to be consumed in database queries. I know I can just throw more CPU and memory to the db instance and hope it works but I think we can do better during delete operation. Correct me if I am wrong but I think this is the code that gets executed when deleting a DAG from UI or CLI via
delete_dag.py
I see we are iterating over all the models and doing a
dag_id
match. Some of the tables don't have an index overdag_id
column likejob
which is making this operation really slow. This could be one easy fix for this issue.For example, the following query took 20 mins to finish in 16cpu 32gb Postgres instance:
and explain is as follows
This is just one of the many queries that are being executed during the delete operation.
What you expected to happen
Deletion of DAG should not take this much time.
How to reproduce
No response
Operating System
nix
Versions of Apache Airflow Providers
No response
Deployment
Other Docker-based deployment
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: