This is an automated email from the ASF dual-hosted git repository.

ephraimbuddy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 968cca0c7e4 Add a dag_run index on (dag_id, run_after) (#74481)
968cca0c7e4 is described below

commit 968cca0c7e47f5dd39d5dcdaf3478e634ed2a438
Author: Yuseok Jo <[email protected]>
AuthorDate: Tue Oct 27 18:35:29 2026 +0900

    Add a dag_run index on (dag_id, run_after) (#74481)
---
 airflow-core/docs/migrations-ref.rst               |  4 +-
 ...150_3_5_0_add_dag_run_dag_id_run_after_index.py | 48 ++++++++++++++++++++++
 airflow-core/src/airflow/models/dagrun.py          |  1 +
 airflow-core/src/airflow/utils/db.py               |  2 +-
 4 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/airflow-core/docs/migrations-ref.rst 
b/airflow-core/docs/migrations-ref.rst
index 922105789ae..af1282ee470 100644
--- a/airflow-core/docs/migrations-ref.rst
+++ b/airflow-core/docs/migrations-ref.rst
@@ -39,7 +39,9 @@ Here's the list of all the Database Migrations that are 
executed via when you ru
 
+-------------------------+------------------+-------------------+--------------------------------------------------------------+
 | Revision ID             | Revises ID       | Airflow Version   | Description 
                                                 |
 
+=========================+==================+===================+==============================================================+
-| ``c71065a1b14f`` (head) | ``ee86eed19e24`` | ``3.5.0``         | Add 
session_id and registration_id to Job.                   |
+| ``38c8df3fcb9c`` (head) | ``c71065a1b14f`` | ``3.5.0``         | Add index 
on dag_run (dag_id, run_after).                    |
++-------------------------+------------------+-------------------+--------------------------------------------------------------+
+| ``c71065a1b14f``        | ``ee86eed19e24`` | ``3.5.0``         | Add 
session_id and registration_id to Job.                   |
 
+-------------------------+------------------+-------------------+--------------------------------------------------------------+
 | ``ee86eed19e24``        | ``9cffe90fa0c0`` | ``3.4.0``         | Add 
pending_partition_key to asset_partition_dag_run and     |
 |                         |                  |                   | enforce 
single pending row per key.                          |
diff --git 
a/airflow-core/src/airflow/migrations/versions/0150_3_5_0_add_dag_run_dag_id_run_after_index.py
 
b/airflow-core/src/airflow/migrations/versions/0150_3_5_0_add_dag_run_dag_id_run_after_index.py
new file mode 100644
index 00000000000..9c5ba748c5f
--- /dev/null
+++ 
b/airflow-core/src/airflow/migrations/versions/0150_3_5_0_add_dag_run_dag_id_run_after_index.py
@@ -0,0 +1,48 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Add index on dag_run (dag_id, run_after).
+
+Revision ID: 38c8df3fcb9c
+Revises: c71065a1b14f
+Create Date: 2026-10-08 22:19:14.965383
+"""
+
+from __future__ import annotations
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "38c8df3fcb9c"
+down_revision = "c71065a1b14f"
+branch_labels = None
+depends_on = None
+airflow_version = "3.5.0"
+
+
+def upgrade():
+    """Add index on dag_run (dag_id, run_after)."""
+    with op.batch_alter_table("dag_run", schema=None) as batch_op:
+        batch_op.create_index("idx_dag_run_dag_id_run_after", ["dag_id", 
"run_after"], unique=False)
+
+
+def downgrade():
+    """Remove index on dag_run (dag_id, run_after)."""
+    with op.batch_alter_table("dag_run", schema=None) as batch_op:
+        batch_op.drop_index("idx_dag_run_dag_id_run_after")
diff --git a/airflow-core/src/airflow/models/dagrun.py 
b/airflow-core/src/airflow/models/dagrun.py
index 206993e1b66..ac0a4f03487 100644
--- a/airflow-core/src/airflow/models/dagrun.py
+++ b/airflow-core/src/airflow/models/dagrun.py
@@ -355,6 +355,7 @@ class DagRun(Base, LoggingMixin):
         UniqueConstraint("dag_id", "logical_date", 
name="dag_run_dag_id_logical_date_key"),
         Index("idx_dag_run_dag_id", dag_id),
         Index("idx_dag_run_run_after", run_after),
+        Index("idx_dag_run_dag_id_run_after", dag_id, run_after),
         Index("idx_dag_run_created_dag_version_id", created_dag_version_id),
         Index(
             "idx_dag_run_running_dags",
diff --git a/airflow-core/src/airflow/utils/db.py 
b/airflow-core/src/airflow/utils/db.py
index 266222bd070..5fb7ac5dfff 100644
--- a/airflow-core/src/airflow/utils/db.py
+++ b/airflow-core/src/airflow/utils/db.py
@@ -118,7 +118,7 @@ _REVISION_HEADS_MAP: dict[str, str] = {
     "3.2.0": "1d6611b6ab7c",
     "3.3.0": "d2f4e1b3c5a7",
     "3.4.0": "ee86eed19e24",
-    "3.5.0": "c71065a1b14f",
+    "3.5.0": "38c8df3fcb9c",
 }
 
 # Prefix used to identify tables holding data moved during migration.

Reply via email to