Skip to content

Commit

Permalink
Remove redundant dag_id index on log table (#42376)
Browse files Browse the repository at this point in the history
This index is not needed because there's another index on the table that leads with dag_id.
  • Loading branch information
dstandish authored Sep 20, 2024
1 parent 0d5b089 commit 0f64f32
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 121 deletions.
49 changes: 49 additions & 0 deletions airflow/migrations/versions/0033_3_0_0_remove_redundant_index.py
Original file line number Diff line number Diff line change
@@ -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.

"""
Remove redundant index.
Revision ID: 16cbcb1c8c36
Revises: 522625f6d606
Create Date: 2024-09-20 09:32:48.707545
"""

from __future__ import annotations

from alembic import op

# revision identifiers, used by Alembic.
revision = "16cbcb1c8c36"
down_revision = "522625f6d606"
branch_labels = None
depends_on = None
airflow_version = "3.0.0"


def upgrade():
"""Apply Remove redundant index."""
with op.batch_alter_table("log", schema=None) as batch_op:
batch_op.drop_index("idx_log_dag")


def downgrade():
"""Unapply Remove redundant index."""
with op.batch_alter_table("log", schema=None) as batch_op:
batch_op.create_index("idx_log_dag", ["dag_id"], unique=False)
1 change: 0 additions & 1 deletion airflow/models/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Log(Base):
try_number = Column(Integer)

__table_args__ = (
Index("idx_log_dag", dag_id),
Index("idx_log_dttm", dttm),
Index("idx_log_event", event),
Index("idx_log_task_instance", dag_id, task_id, run_id, map_index, try_number),
Expand Down
2 changes: 1 addition & 1 deletion airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class MappedClassProtocol(Protocol):
"2.9.0": "1949afb29106",
"2.9.2": "686269002441",
"2.10.0": "22ed7efa9da2",
"3.0.0": "522625f6d606",
"3.0.0": "16cbcb1c8c36",
}


Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/img/airflow_erd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d58a76011bd215ac7a0c42146986ad0eead5f4a9c8ffd7932b1aa1eb61e6e4af
f4379048d3f13f35aaba824c00450c17ad4deea9af82b5498d755a12f8a85a37
Loading

0 comments on commit 0f64f32

Please sign in to comment.