Airflow Database

Complete Guide to Airflow database in 2023

Welcome to this blog, where we will delve into the world of the Airflow database. We will explore the significance of having an Airflow database and take a closer look at the various tables it contains. So, without further delay, let’s dive in.

Why do we need a database for airflow?

The database is a critical component of Airflow’s architecture and it is used to store metadata related to workflows. It enables users to define and configure DAGs, tasks, and other workflow elements, and track their status and execution history.

The database also stores configuration variables and secrets, which can be used to configure DAGs or other tasks. Additionally, the database facilitates cross-task communication and allows users to monitor and debug workflows using SQL queries.

Overall, the database plays a crucial role in enabling Airflow’s workflow orchestration capabilities, providing a centralized location for storing and managing metadata related to workflows.

Various types of databases supported in airflow

Airflow supports several types of databases as the backend for its metadata database. Below are the main database types supported by Airflow:

  • PostgreSQL
  • MySQL
  • SQLite
  • Microsoft SQL Server
  • Oracle
  • Amazon Redshift

Choosing the right database for Airflow depends on various factors such as performance, scalability, reliability, and cost.

Among all the supported databases, PostgreSQL is the recommended option as it provides excellent performance and scalability for large-scale deployments.

However, MySQL can also be used, although it may not perform as well as PostgreSQL for large-scale deployments.

Tables in the airflow database

The Airflow metadata database consists of several tables that store information about DAG, tasks, runs, and other information. Below are the main tables in the Airflow database:

  • dag – Contains information about the DAGs defined in Airflow, such as the DAG’s name, description, and default arguments.
  • dag_run – Contains information about each DAG run, such as the execution date, etc.
  • task_instance – Contains information about each instance of a task within a DAG run, such as the task’s state, start and end times, and duration.
  • log – Contains the logs generated by each task instance during its execution.
  • job – Contains information about the jobs executed by Airflow, such as the start and end times and the status of the job.
  • variable – Stores key-value pairs that can be used in DAGs for configuration or other purposes.
  • connection – Contains information about the external systems or services that Airflow can connect to.
  • sla_miss – Contains information about SLA misses for task instances.
  • task_fail – Contains information about task failures, such as the task instance and the error message.
  • xcom – Contains information about cross-communication messages between tasks

These are the main tables in the Airflow metadata database, although there may be additional tables depending on the specific configuration and usage of Airflow.

How to access the airflow database

There are multiple ways to access the data stored in the Airflow database, such as through the web UI or the CLI.

The Airflow web UI allows users to access connections, DAG details, and the status of each DAG and their runs. It also allows users to verify the logs stored in the Airflow database.

The Airflow CLI provides another method to access the Airflow metadata, enabling users to retrieve information such as DAG runs, logs, and DAG status using command-line queries. Follow the below link to understand various airflow CLI commands

Airflow CLI commands

Additionally, SQL client tools such as SQLiteStudio can be used to connect directly to the Airflow database and run SQL queries against the metadata. The connection information and credentials can be found in the Airflow configuration file.

Airflow database size

By default, Airflow uses SQLite as its backend database and its size limit are 140 terabytes, but it is not recommended for production environments due to its limited scalability and performance.

For larger deployments, it is recommended to use PostgreSQL or MySQL as the backend database. The size limit for these databases is much larger and can be scaled horizontally to handle larger amounts of metadata.

However, the actual size of the database will depend on the number of DAGs, tasks, runs, and other metadata being stored, as well as the frequency and volume of data being processed by Airflow.


In conclusion, the Airflow database is a crucial component that provides a centralized location for storing metadata related to workflows. The choice of the database depends on specific requirements, such as performance, scalability, reliability, and cost.

The right choice must be made based on these factors. Regardless of the database used, it is essential to regularly maintain and optimize the database to ensure optimal performance and prevent issues.

More to explore

Airflow BashOperator

Airflow DummyOperator

Airflow PythonOperator

How to send email from airflow

How to integrate airflow with slack

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top