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

kaxilnaik 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 c57c23dce3 Add index on log.dttm (#28944)
c57c23dce3 is described below

commit c57c23dce39992eafcf86dc08a1938d7d407803f
Author: Ping Zhang <[email protected]>
AuthorDate: Sun Jan 15 10:35:02 2023 -0800

    Add index on log.dttm (#28944)
    
    log table tends to be very large. Having an index around `dttm` can
    greatly improve the query performance when trying to filter log records
    in a period of time
---
 .../0123_2_6_0_add_dttm_index_on_log_table.py      | 45 ++++++++++++++++++++++
 airflow/models/log.py                              |  1 +
 docs/apache-airflow/img/airflow_erd.sha256         |  2 +-
 docs/apache-airflow/migrations-ref.rst             |  4 +-
 4 files changed, 50 insertions(+), 2 deletions(-)

diff --git 
a/airflow/migrations/versions/0123_2_6_0_add_dttm_index_on_log_table.py 
b/airflow/migrations/versions/0123_2_6_0_add_dttm_index_on_log_table.py
new file mode 100644
index 0000000000..0e3e935ef8
--- /dev/null
+++ b/airflow/migrations/versions/0123_2_6_0_add_dttm_index_on_log_table.py
@@ -0,0 +1,45 @@
+#
+# 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 dttm index on log table
+
+Revision ID: 6abdffdd4815
+Revises: 290244fb8b83
+Create Date: 2023-01-13 13:57:14.412028
+
+"""
+from __future__ import annotations
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "6abdffdd4815"
+down_revision = "290244fb8b83"
+branch_labels = None
+depends_on = None
+airflow_version = "2.6.0"
+
+
+def upgrade():
+    """Apply add dttm index on log table"""
+    op.create_index("idx_log_dttm", "log", ["dttm"], unique=False)
+
+
+def downgrade():
+    """Unapply add dttm index on log table"""
+    op.drop_index("idx_log_dttm", table_name="log")
diff --git a/airflow/models/log.py b/airflow/models/log.py
index 7994abc463..33fdeaee07 100644
--- a/airflow/models/log.py
+++ b/airflow/models/log.py
@@ -41,6 +41,7 @@ class Log(Base):
 
     __table_args__ = (
         Index("idx_log_dag", dag_id),
+        Index("idx_log_dttm", dttm),
         Index("idx_log_event", event),
     )
 
diff --git a/docs/apache-airflow/img/airflow_erd.sha256 
b/docs/apache-airflow/img/airflow_erd.sha256
index 0a993447a5..e2035b9f85 100644
--- a/docs/apache-airflow/img/airflow_erd.sha256
+++ b/docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
-edb1bcac449e2d38c4523cea6094e812da491a01c40cf9f79024d85e69977893
\ No newline at end of file
+369a505e0505cb07d99b1ae3a2bbf46637c24fd36e5b5d185547c10c8292278d
\ No newline at end of file
diff --git a/docs/apache-airflow/migrations-ref.rst 
b/docs/apache-airflow/migrations-ref.rst
index a4919749d4..0391380c08 100644
--- a/docs/apache-airflow/migrations-ref.rst
+++ b/docs/apache-airflow/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                                                  |
 
+=================================+===================+===================+==============================================================+
-| ``290244fb8b83`` (head)         | ``1986afd32c1b``  | ``2.5.0``         | 
Add is_orphaned to DatasetModel                              |
+| ``6abdffdd4815`` (head)         | ``290244fb8b83``  | ``2.6.0``         | 
add dttm index on log table                                  |
++---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
+| ``290244fb8b83``                | ``1986afd32c1b``  | ``2.5.0``         | 
Add is_orphaned to DatasetModel                              |
 
+---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
 | ``1986afd32c1b``                | ``ee8d93fcc81e``  | ``2.5.0``         | 
Add DagRunNote and TaskInstanceNote                          |
 
+---------------------------------+-------------------+-------------------+--------------------------------------------------------------+

Reply via email to