On September 15, 2026, all Cloud Composer 1 versions and versions 2.0.x of Cloud Composer 2 will reach their planned end of life. You will not be able to use environments with these versions. We recommend planning migration to Cloud Composer 3. Cloud Composer 2 versions 2.1.x and later are still supported and are not impacted by this change.
This page explains how to maintain the Airflow database in your environment.
Automatic database cleanup with a database retention policy
You can configure automatic database cleanup for your Cloud Composer 3
environment by setting a database retention policy. After you set up this
policy, records older than a certain period are automatically removed from the
Airflow database daily. For more information, see
Configure database retention policy.
Deprecated cleanup procedures
Before the database retention policy became available in
Cloud Composer, we recommended a different approach for automating
the database cleanup, through a database cleanup DAG. This
approach is obsolete in Cloud Composer 3. This DAG does redundant work and you
can reduce the resource consumption by removing it and replacing it with a
database retention policy.
Limits for database size
As the time goes, the Airflow database of your environment stores more and
more data. This data includes information and logs related to past DAG runs,
tasks, and other Airflow operations.
If the Airflow database size is more than
20 GB,
then you can't upgrade your environment to a later version.
If the Airflow database size is more than 20 GB,
it is not possible to create snapshots.
Maintain database performance
Airflow database performance issues can lead to overall DAG execution
issues.
Observe Database CPU and memory usage
statistics. If CPU and memory utilization approaches the limits, then the
database is overloaded and requires scaling.
The amount of resources available to the Airflow database is controlled by
the environment size property of your environment. To scale the database up
change the environment size to a larger tier. Increasing the
environment size increases the costs of your environment.
If you use the XCom mechanism to transfer files, make sure that you
use it according to Airflow's guidelines.
Transferring big files or a large number of files using XCom impacts
Airflow database's performance and can lead to failures when loading
snapshots or upgrading your environment. Consider using alternatives such
as Cloud Storage to transfer large volumes of data.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThis page outlines how to manually clean up the Airflow database in Cloud Composer 3 environments, as well as automatic alternatives.\u003c/p\u003e\n"],["\u003cp\u003eCloud Composer offers a database retention policy that automatically removes records older than a specified period, and it is preferred over the older database cleanup DAG.\u003c/p\u003e\n"],["\u003cp\u003eExceeding a 20 GB database size in Airflow prevents environment upgrades and snapshot creation, making regular cleanup essential.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud composer environments run\u003c/code\u003e command can be used to manually trim the database, removing entries older than the specified retention period.\u003c/p\u003e\n"],["\u003cp\u003eDatabase performance issues can cause DAG execution problems, and scaling up the environment size can address these issues, while also using proper Xcom practices to avoid issues with the database.\u003c/p\u003e\n"]]],[],null,["# Clean up the Airflow database\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n**Cloud Composer 3** \\| [Cloud Composer 2](/composer/docs/composer-2/cleanup-airflow-database \"View this page for Cloud Composer 2\") \\| [Cloud Composer 1](/composer/docs/composer-1/cleanup-airflow-database \"View this page for Cloud Composer 1\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page explains how to maintain the Airflow database in your environment.\n\nAutomatic database cleanup with a database retention policy\n-----------------------------------------------------------\n\nYou can configure automatic database cleanup for your Cloud Composer 3\nenvironment by setting a database retention policy. After you set up this\npolicy, records older than a certain period are automatically removed from the\nAirflow database daily. For more information, see\n[Configure database retention policy](/composer/docs/composer-3/configure-db-retention).\n\nDeprecated cleanup procedures\n-----------------------------\n\n| **Deprecated:** The **maintenance DAG approach is obsolete** in Cloud Composer 3. If you still use the database maintenance DAG, we recommend to remove or pause it and configure a [database retention policy](/composer/docs/composer-3/configure-db-retention) instead.\n\nBefore the database retention policy became available in\nCloud Composer, we recommended a different approach for automating\nthe database cleanup, through a [database cleanup DAG](/composer/docs/composer-2/cleanup-airflow-database). This\napproach is obsolete in Cloud Composer 3. This DAG does redundant work and you\ncan reduce the resource consumption by removing it and replacing it with a\n[database retention policy](/composer/docs/composer-3/configure-db-retention).\n\nLimits for database size\n------------------------\n\nAs the time goes, the Airflow database of your environment stores more and\nmore data. This data includes information and logs related to past DAG runs,\ntasks, and other Airflow operations.\n\n- If the Airflow database size is more than\n 20 GB,\n then you can't upgrade your environment to a later version.\n\n- If the Airflow database size is more than 20 GB,\n it is not possible to create snapshots.\n\nMaintain database performance\n-----------------------------\n\n- Airflow database performance issues can lead to overall DAG execution\n issues.\n [Observe Database CPU and memory usage](/composer/docs/composer-3/use-monitoring-dashboard#db-statistics)\n statistics. If CPU and memory utilization approaches the limits, then the\n database is overloaded and requires scaling.\n\n The amount of resources available to the Airflow database is controlled by\n the environment size property of your environment. To scale the database up\n [change the environment size](/composer/docs/composer-3/scale-environments) to a larger tier. Increasing the\n environment size increases the costs of your environment.\n\n- If you use the XCom mechanism to transfer files, make sure that you\n [use it according to Airflow's guidelines](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/xcoms.html#object-storage-xcom-backend).\n Transferring big files or a large number of files using XCom impacts\n Airflow database's performance and can lead to failures when loading\n snapshots or upgrading your environment. Consider using alternatives such\n as Cloud Storage to transfer large volumes of data.\n\nRemove entries for unused DAGs\n------------------------------\n\nYou can remove database entries for unused DAGs by\n[removing DAGs from the Airflow UI](/composer/docs/composer-3/manage-dags#delete-md).\n\nWhat's next\n-----------\n\n- [Configure database retention policy](/composer/docs/composer-3/configure-db-retention)\n- [Access Airflow command-line interface](/composer/docs/composer-3/access-airflow-cli)"]]