This is an automated email from the ASF dual-hosted git repository.
kaxil 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 655740bb982 Add new index for trigger (#69038)
655740bb982 is described below
commit 655740bb98282ca64d5bde2aeec65da8c56b1930
Author: AutomationDev85 <[email protected]>
AuthorDate: Mon Aug 10 23:49:28 2026 +0200
Add new index for trigger (#69038)
Co-authored-by: AutomationDev85 <AutomationDev85>
---
airflow-core/docs/migrations-ref.rst | 4 +-
.../0130_3_4_0_add_new_index_for_trigger.py | 49 ++++++++++++++++++++++
airflow-core/src/airflow/models/trigger.py | 3 +-
airflow-core/src/airflow/utils/db.py | 2 +-
4 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/airflow-core/docs/migrations-ref.rst
b/airflow-core/docs/migrations-ref.rst
index 691720f6508..b6f7fbcf879 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
|
+=========================+==================+===================+==============================================================+
-| ``3c525f44bea8`` (head) | ``b2f1a9c7d4e0`` | ``3.4.0`` | Add indexes
on serialized_dag and dag_code. |
+| ``76c46545c91e`` (head) | ``3c525f44bea8`` | ``3.4.0`` | Add new
index for trigger. |
++-------------------------+------------------+-------------------+--------------------------------------------------------------+
+| ``3c525f44bea8`` | ``b2f1a9c7d4e0`` | ``3.4.0`` | Add indexes
on serialized_dag and dag_code. |
+-------------------------+------------------+-------------------+--------------------------------------------------------------+
| ``b2f1a9c7d4e0`` | ``7a98f1b7dbd3`` | ``3.4.0`` | Reference
the asset event from asset_dag_run_queue (consume- |
| | | |
by-reference). |
diff --git
a/airflow-core/src/airflow/migrations/versions/0130_3_4_0_add_new_index_for_trigger.py
b/airflow-core/src/airflow/migrations/versions/0130_3_4_0_add_new_index_for_trigger.py
new file mode 100644
index 00000000000..74fb65125cb
--- /dev/null
+++
b/airflow-core/src/airflow/migrations/versions/0130_3_4_0_add_new_index_for_trigger.py
@@ -0,0 +1,49 @@
+#
+# 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 new index for trigger.
+
+Revision ID: 76c46545c91e
+Revises: 3c525f44bea8
+Create Date: 2026-07-13 11:06:57.281704
+
+"""
+
+from __future__ import annotations
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "76c46545c91e"
+down_revision = "3c525f44bea8"
+branch_labels = None
+depends_on = None
+airflow_version = "3.4.0"
+
+
+def upgrade():
+ """Add new index for trigger."""
+ with op.batch_alter_table("trigger", schema=None) as batch_op:
+ batch_op.create_index("idx_trigger_triggerer_queue_id",
["triggerer_id", "queue", "id"], unique=False)
+
+
+def downgrade():
+ """Remove new index for trigger."""
+ with op.batch_alter_table("trigger", schema=None) as batch_op:
+ batch_op.drop_index("idx_trigger_triggerer_queue_id")
diff --git a/airflow-core/src/airflow/models/trigger.py
b/airflow-core/src/airflow/models/trigger.py
index a49d4bba279..4915637c88d 100644
--- a/airflow-core/src/airflow/models/trigger.py
+++ b/airflow-core/src/airflow/models/trigger.py
@@ -24,7 +24,7 @@ from functools import singledispatch
from traceback import format_exception
from typing import TYPE_CHECKING, Any
-from sqlalchemy import ForeignKey, Integer, String, Text, delete, func, or_,
select, update
+from sqlalchemy import ForeignKey, Index, Integer, String, Text, delete, func,
or_, select, update
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.orm import Mapped, Session, mapped_column, relationship,
selectinload
from sqlalchemy.sql.functions import coalesce
@@ -92,6 +92,7 @@ class Trigger(Base):
"""
__tablename__ = "trigger"
+ __table_args__ = (Index("idx_trigger_triggerer_queue_id", "triggerer_id",
"queue", "id"),)
id: Mapped[int] = mapped_column(Integer, primary_key=True)
classpath: Mapped[str] = mapped_column(String(1000), nullable=False)
diff --git a/airflow-core/src/airflow/utils/db.py
b/airflow-core/src/airflow/utils/db.py
index 7dcb15c7423..4b873b4214e 100644
--- a/airflow-core/src/airflow/utils/db.py
+++ b/airflow-core/src/airflow/utils/db.py
@@ -117,7 +117,7 @@ _REVISION_HEADS_MAP: dict[str, str] = {
"3.1.8": "509b94a1042d",
"3.2.0": "1d6611b6ab7c",
"3.3.0": "d2f4e1b3c5a7",
- "3.4.0": "3c525f44bea8",
+ "3.4.0": "76c46545c91e",
}
# Prefix used to identify tables holding data moved during migration.