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

potiuk 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 2af2ddca06 Added index on taskinstance which includes the start_date 
column (#30762)
2af2ddca06 is described below

commit 2af2ddca06e0c7339ea2c6d84ac9391bff6128e7
Author: Babis <[email protected]>
AuthorDate: Mon May 8 20:40:26 2023 +0100

    Added index on taskinstance which includes the start_date column (#30762)
---
 .../0125_2_7_0_add_index_to_task_instance_table.py |  50 ++++++++
 airflow/models/taskinstance.py                     |   9 ++
 docs/apache-airflow/img/airflow_erd.sha256         |   2 +-
 docs/apache-airflow/img/airflow_erd.svg            | 136 ++++++++++-----------
 docs/apache-airflow/migrations-ref.rst             |   4 +-
 newsfragments/30762.improvement.rst                |   1 +
 6 files changed, 132 insertions(+), 70 deletions(-)

diff --git 
a/airflow/migrations/versions/0125_2_7_0_add_index_to_task_instance_table.py 
b/airflow/migrations/versions/0125_2_7_0_add_index_to_task_instance_table.py
new file mode 100644
index 0000000000..b9a1df82fd
--- /dev/null
+++ b/airflow/migrations/versions/0125_2_7_0_add_index_to_task_instance_table.py
@@ -0,0 +1,50 @@
+#
+# 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 to task_instance table
+
+Revision ID: 937cbd173ca1
+Revises: 98ae134e6fff
+Create Date: 2023-05-03 11:31:32.527362
+
+"""
+from __future__ import annotations
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "937cbd173ca1"
+down_revision = "98ae134e6fff"
+branch_labels = None
+depends_on = None
+airflow_version = "2.7.0"
+
+
+def upgrade():
+    """Apply Add index to task_instance table"""
+    op.create_index(
+        "ti_state_incl_start_date",
+        "task_instance",
+        ["dag_id", "task_id", "state"],
+        postgresql_include=["start_date"],
+    )
+
+
+def downgrade():
+    """Unapply Add index to task_instance table"""
+    op.drop_index("ti_state_incl_start_date", table_name="task_instance")
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index 43db0ffef8..d392c604f0 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -423,6 +423,15 @@ class TaskInstance(Base, LoggingMixin):
         Index("ti_dag_run", dag_id, run_id),
         Index("ti_state", state),
         Index("ti_state_lkp", dag_id, task_id, run_id, state),
+        # The below index has been added to improve performance on postgres 
setups with tens of millions of
+        # taskinstance rows. Aim is to improve the below query (it can be used 
to find the last successful
+        # execution date of a task instance):
+        #    SELECT start_date FROM task_instance WHERE dag_id = 'xx' AND 
task_id = 'yy' AND state = 'success'
+        #    ORDER BY start_date DESC NULLS LAST LIMIT 1;
+        # Existing "ti_state_lkp" is not enough for such query when this table 
has millions of rows, since
+        # rows have to be fetched in order to retrieve the start_date column. 
With this index, INDEX ONLY SCAN
+        # is performed and that query runs within milliseconds.
+        Index("ti_state_incl_start_date", dag_id, task_id, state, 
postgresql_include=["start_date"]),
         Index("ti_pool", pool, state, priority_weight),
         Index("ti_job_id", job_id),
         Index("ti_trigger_id", trigger_id),
diff --git a/docs/apache-airflow/img/airflow_erd.sha256 
b/docs/apache-airflow/img/airflow_erd.sha256
index ded035ba22..bc462539ad 100644
--- a/docs/apache-airflow/img/airflow_erd.sha256
+++ b/docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
-b409a0826f10dc5ef934616fe2d5e72fff322bb1aebe321aad475e4d72c25a4f
\ No newline at end of file
+87f70d3f35c883e544ce7fe6337227c000a9cf995d148648ab19a931b490ecb8
\ No newline at end of file
diff --git a/docs/apache-airflow/img/airflow_erd.svg 
b/docs/apache-airflow/img/airflow_erd.svg
index f9895d3c6e..b531759ac4 100644
--- a/docs/apache-airflow/img/airflow_erd.svg
+++ b/docs/apache-airflow/img/airflow_erd.svg
@@ -507,8 +507,8 @@
 <g id="edge11" class="edge">
 <title>dag&#45;&#45;dag_owner_attributes</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M383.23,-3245.29C407.08,-3228.35 431.66,-3212.16 456,-3198 463.82,-3193.45 
472.02,-3189.06 480.4,-3184.86"/>
-<text text-anchor="start" x="449.4" y="-3173.66" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="383.23" y="-3234.09" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="470.4" y="-3173.66" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="383.23" y="-3234.09" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dag_schedule_dataset_reference -->
 <g id="node16" class="node">
@@ -536,8 +536,8 @@
 <g id="edge12" class="edge">
 <title>dag&#45;&#45;dag_schedule_dataset_reference</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M383.09,-3582.17C406.92,-3601.29 431.53,-3619.69 456,-3636 460.57,-3639.05 
465.28,-3642.04 470.09,-3644.98"/>
-<text text-anchor="start" x="439.09" y="-3633.78" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="383.09" y="-3570.97" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="460.09" y="-3633.78" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="383.09" y="-3570.97" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dag_tag -->
 <g id="node17" class="node">
@@ -557,8 +557,8 @@
 <g id="edge13" class="edge">
 <title>dag&#45;&#45;dag_tag</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M383.21,-3404C416.02,-3404 449.48,-3404 480.38,-3404"/>
-<text text-anchor="start" x="449.38" y="-3392.8" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="383.21" y="-3392.8" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="470.38" y="-3392.8" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="383.21" y="-3392.8" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dag_warning -->
 <g id="node18" class="node">
@@ -586,8 +586,8 @@
 <g id="edge14" class="edge">
 <title>dag&#45;&#45;dag_warning</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M383.21,-3345.63C409.26,-3337.66 435.72,-3329.56 460.99,-3321.83"/>
-<text text-anchor="start" x="429.99" y="-3310.63" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="383.21" y="-3334.43" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="450.99" y="-3310.63" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="383.21" y="-3334.43" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dataset_dag_run_queue -->
 <g id="node19" class="node">
@@ -611,8 +611,8 @@
 <g id="edge15" class="edge">
 <title>dag&#45;&#45;dataset_dag_run_queue</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M383.2,-3719.15C405.83,-3744.92 430.15,-3769.05 456,-3790 460.03,-3793.27 
464.25,-3796.39 468.61,-3799.38"/>
-<text text-anchor="start" x="437.61" y="-3788.18" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="383.2" y="-3707.95" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="458.61" y="-3788.18" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="383.2" y="-3707.95" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_outlet_dataset_reference -->
 <g id="node20" class="node">
@@ -644,8 +644,8 @@
 <g id="edge16" class="edge">
 <title>dag&#45;&#45;task_outlet_dataset_reference</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M383.21,-3468.25C411.11,-3477.65 439.49,-3487.21 466.36,-3496.26"/>
-<text text-anchor="start" x="435.36" y="-3485.06" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="383.21" y="-3457.05" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="456.36" y="-3485.06" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="383.21" y="-3457.05" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dag_code -->
 <g id="node21" class="node">
@@ -757,8 +757,8 @@
 <g id="edge17" class="edge">
 <title>dag_run&#45;&#45;dag_run_note</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M766.73,-1153.42C792.44,-1184.06 819.69,-1214.58 847,-1242 858.89,-1253.94 
871.97,-1265.86 885.23,-1277.27"/>
-<text text-anchor="start" x="854.23" y="-1266.07" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="766.73" y="-1142.22" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="875.23" y="-1266.07" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="766.73" y="-1142.22" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dagrun_dataset_event -->
 <g id="node24" class="node">
@@ -778,8 +778,8 @@
 <g id="edge18" class="edge">
 <title>dag_run&#45;&#45;dagrun_dataset_event</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M766.71,-1054.25C781.28,-1063.72 795.89,-1073.1 810,-1082 844.83,-1103.95 
884,-1127.47 916.97,-1146.93"/>
-<text text-anchor="start" x="885.97" y="-1135.73" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="766.71" y="-1043.05" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="906.97" y="-1135.73" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="766.71" y="-1043.05" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance -->
 <g id="node25" class="node">
@@ -881,15 +881,15 @@
 <g id="edge19" class="edge">
 <title>dag_run&#45;&#45;task_instance</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M766.64,-826.26C793.11,-804.98 820.6,-783.07 846.89,-762.31"/>
-<text text-anchor="start" x="815.89" y="-751.11" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="766.64" y="-815.06" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="836.89" y="-751.11" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="766.64" y="-815.06" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dag_run&#45;&#45;task_instance -->
 <g id="edge20" class="edge">
 <title>dag_run&#45;&#45;task_instance</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M766.64,-839.53C793.11,-818.59 820.6,-796.65 846.89,-775.49"/>
-<text text-anchor="start" x="815.89" y="-779.29" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="766.64" y="-843.33" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="836.89" y="-779.29" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="766.64" y="-843.33" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_reschedule -->
 <g id="node26" class="node">
@@ -942,70 +942,70 @@
 <title>dag_run&#45;&#45;task_reschedule</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M766.64,-1001.52C793.09,-1009.57 820.6,-1016.93 847,-1022 967.39,-1045.13 
1106.21,-1051.58 1209.82,-1053.9"/>
 <text text-anchor="start" x="1178.82" y="-1042.7" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="766.64" y="-990.32" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="766.64" y="-990.32" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dag_run&#45;&#45;task_reschedule -->
 <g id="edge22" class="edge">
 <title>dag_run&#45;&#45;task_reschedule</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M766.64,-1019.24C793.09,-1027.57 820.6,-1034.93 847,-1040 967.39,-1063.13 
1106.21,-1069.58 1209.82,-1069.19"/>
 <text text-anchor="start" x="1178.82" y="-1057.99" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="766.64" y="-1008.04" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="766.64" y="-1008.04" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_instance_note -->
 <g id="edge36" class="edge">
 <title>task_instance&#45;&#45;task_instance_note</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1117.33,-1022.27C1143.5,-1078.87 1174.26,-1134.76 1210,-1184 
1219.09,-1196.53 1229.71,-1208.54 1241.05,-1219.97"/>
-<text text-anchor="start" x="1210.05" y="-1208.77" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1117.33" y="-1026.07" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1231.05" y="-1208.77" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1107.33" y="-1026.07" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_instance_note -->
 <g id="edge37" class="edge">
 <title>task_instance&#45;&#45;task_instance_note</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1109.28,-1022.22C1137.13,-1085.12 1170.52,-1147.62 1210,-1202 
1215.31,-1209.32 1221.15,-1216.46 1227.34,-1223.4"/>
-<text text-anchor="start" x="1196.34" y="-1227.2" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1068.28" y="-1026.02" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1217.34" y="-1212.2" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1099.28" y="-1026.02" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_instance_note -->
 <g id="edge38" class="edge">
 <title>task_instance&#45;&#45;task_instance_note</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1101.68,-1022.35C1131,-1091.46 1166.86,-1160.58 1210,-1220 1215.31,-1227.32 
1221.15,-1234.46 1227.34,-1241.38"/>
-<text text-anchor="start" x="1196.34" y="-1245.18" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1101.68" y="-1011.15" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1217.34" y="-1230.18" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1091.68" y="-1026.15" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_instance_note -->
 <g id="edge39" class="edge">
 <title>task_instance&#45;&#45;task_instance_note</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1094.36,-1022.29C1124.97,-1097.67 1163.21,-1173.54 1210,-1238 
1215.31,-1245.32 1221.15,-1252.46 1227.34,-1259.36"/>
-<text text-anchor="start" x="1196.34" y="-1263.16" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1053.36" y="-1026.09" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1217.34" y="-1248.16" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1084.36" y="-1026.09" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_reschedule -->
 <g id="edge44" class="edge">
 <title>task_instance&#45;&#45;task_reschedule</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.23,-799.58C1161.15,-826.59 1185.98,-854.33 1210,-880 1220.94,-891.7 
1232.52,-903.7 1244.23,-915.71"/>
 <text text-anchor="start" x="1213.23" y="-904.51" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.23" y="-788.38" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.23" y="-788.38" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_reschedule -->
 <g id="edge45" class="edge">
 <title>task_instance&#45;&#45;task_reschedule</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.23,-817.34C1161.15,-844.59 1185.98,-872.33 1210,-898 1215.54,-903.92 
1221.23,-909.91 1227.03,-915.94"/>
 <text text-anchor="start" x="1196.03" y="-904.74" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.23" y="-806.14" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.23" y="-806.14" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_reschedule -->
 <g id="edge46" class="edge">
 <title>task_instance&#45;&#45;task_reschedule</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.23,-835.1C1161.05,-862.48 1185.79,-890.11 1209.72,-915.7"/>
 <text text-anchor="start" x="1178.72" y="-919.5" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.23" y="-823.9" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.23" y="-823.9" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_reschedule -->
 <g id="edge47" class="edge">
 <title>task_instance&#45;&#45;task_reschedule</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.23,-852.86C1161.05,-880.48 1185.79,-908.11 1209.72,-933.7"/>
 <text text-anchor="start" x="1178.72" y="-937.5" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.23" y="-841.66" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.23" y="-841.66" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- rendered_task_instance_fields -->
 <g id="node33" class="node">
@@ -1040,29 +1040,29 @@
 <g id="edge28" class="edge">
 <title>task_instance&#45;&#45;rendered_task_instance_fields</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1127.99,-285.94C1151.99,-243.8 1179.29,-203.35 1210,-168 1212.53,-165.08 
1215.17,-162.21 1217.9,-159.4"/>
-<text text-anchor="start" x="1186.9" y="-148.2" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1086.99" y="-274.74" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1207.9" y="-148.2" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1117.99" y="-274.74" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;rendered_task_instance_fields -->
 <g id="edge29" class="edge">
 <title>task_instance&#45;&#45;rendered_task_instance_fields</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.12,-288.15C1158.85,-251.79 1183.12,-216.94 1210,-186 1212.53,-183.08 
1215.17,-180.21 1217.9,-177.4"/>
-<text text-anchor="start" x="1186.9" y="-166.2" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.12" y="-276.95" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1207.9" y="-166.2" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.12" y="-276.95" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;rendered_task_instance_fields -->
 <g id="edge30" class="edge">
 <title>task_instance&#45;&#45;rendered_task_instance_fields</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.12,-306.05C1158.85,-269.79 1183.12,-234.94 1210,-204 1215.39,-197.8 
1221.24,-191.82 1227.41,-186.07"/>
-<text text-anchor="start" x="1196.41" y="-189.87" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.12" y="-294.85" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1217.41" y="-189.87" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.12" y="-294.85" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;rendered_task_instance_fields -->
 <g id="edge31" class="edge">
 <title>task_instance&#45;&#45;rendered_task_instance_fields</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.12,-323.94C1158.85,-287.79 1183.12,-252.94 1210,-222 1221.2,-209.11 
1234.4,-197.19 1248.3,-186.14"/>
-<text text-anchor="start" x="1248.3" y="-189.94" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.12" y="-312.74" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1238.3" y="-189.94" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.12" y="-312.74" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_fail -->
 <g id="node34" class="node">
@@ -1104,28 +1104,28 @@
 <title>task_instance&#45;&#45;task_fail</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-683.02C1167.64,-692.68 1199.78,-703.64 1229.98,-714.71"/>
 <text text-anchor="start" x="1198.98" y="-703.51" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-671.82" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.09" y="-671.82" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_fail -->
 <g id="edge33" class="edge">
 <title>task_instance&#45;&#45;task_fail</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-696.21C1167.64,-706.33 1199.78,-717.24 1229.98,-727.75"/>
 <text text-anchor="start" x="1198.98" y="-731.55" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-700.01" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.09" y="-700.01" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_fail -->
 <g id="edge34" class="edge">
 <title>task_instance&#45;&#45;task_fail</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-709.4C1167.64,-719.98 1199.78,-730.84 1229.98,-740.79"/>
 <text text-anchor="start" x="1198.98" y="-744.59" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-713.2" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.09" y="-713.2" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_fail -->
 <g id="edge35" class="edge">
 <title>task_instance&#45;&#45;task_fail</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-722.59C1167.64,-733.63 1199.78,-744.44 1229.98,-753.83"/>
 <text text-anchor="start" x="1198.98" y="-757.63" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-726.39" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.09" y="-726.39" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_map -->
 <g id="node35" class="node">
@@ -1160,29 +1160,29 @@
 <g id="edge40" class="edge">
 <title>task_instance&#45;&#45;task_map</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-594.32C1167.64,-585.17 1199.78,-576.35 1229.98,-568.83"/>
-<text text-anchor="start" x="1198.98" y="-557.63" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-583.12" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1219.98" y="-557.63" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.09" y="-583.12" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_map -->
 <g id="edge41" class="edge">
 <title>task_instance&#45;&#45;task_map</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-607.51C1167.64,-598.82 1199.78,-589.95 1229.98,-581.87"/>
-<text text-anchor="start" x="1198.98" y="-585.67" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-611.31" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1219.98" y="-585.67" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.09" y="-611.31" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_map -->
 <g id="edge42" class="edge">
 <title>task_instance&#45;&#45;task_map</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-620.7C1167.64,-612.47 1199.78,-603.55 1229.98,-594.9"/>
-<text text-anchor="start" x="1198.98" y="-598.7" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-624.5" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1219.98" y="-598.7" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.09" y="-624.5" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;task_map -->
 <g id="edge43" class="edge">
 <title>task_instance&#45;&#45;task_map</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.09,-633.89C1167.64,-626.12 1199.78,-617.14 1229.98,-607.94"/>
-<text text-anchor="start" x="1198.98" y="-611.74" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.09" y="-637.69" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1219.98" y="-611.74" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.09" y="-637.69" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- xcom -->
 <g id="node36" class="node">
@@ -1226,28 +1226,28 @@
 <title>task_instance&#45;&#45;xcom</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.01,-488.65C1161.12,-465.83 1186.07,-443.06 1210,-422 1216.27,-416.48 
1222.72,-410.89 1229.27,-405.29"/>
 <text text-anchor="start" x="1198.27" y="-394.09" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.01" y="-477.45" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.01" y="-477.45" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;xcom -->
 <g id="edge49" class="edge">
 <title>task_instance&#45;&#45;xcom</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.01,-506.4C1161.12,-483.83 1186.07,-461.06 1210,-440 1216.27,-434.48 
1222.72,-428.89 1229.27,-423.28"/>
 <text text-anchor="start" x="1198.27" y="-412.08" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.01" y="-495.2" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1137.01" y="-495.2" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;xcom -->
 <g id="edge50" class="edge">
 <title>task_instance&#45;&#45;xcom</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.01,-524.15C1161.12,-501.83 1186.07,-479.06 1210,-458 1216.66,-452.14 
1223.53,-446.19 1230.5,-440.21"/>
-<text text-anchor="start" x="1199.5" y="-444.01" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.01" y="-512.95" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1220.5" y="-444.01" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.01" y="-512.95" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- task_instance&#45;&#45;xcom -->
 <g id="edge51" class="edge">
 <title>task_instance&#45;&#45;xcom</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M1137.01,-541.9C1161.12,-519.83 1186.07,-497.06 1210,-476 1223.32,-464.28 
1237.48,-452.19 1251.63,-440.12"/>
-<text text-anchor="start" x="1251.63" y="-443.92" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="1137.01" y="-530.7" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="1241.63" y="-443.92" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="1137.01" y="-530.7" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- log_template -->
 <g id="node27" class="node">
@@ -1312,22 +1312,22 @@
 <g id="edge24" class="edge">
 <title>dataset&#45;&#45;dag_schedule_dataset_reference</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M330.22,-3802.54C370.33,-3789.89 414.46,-3775.96 455.73,-3762.94"/>
-<text text-anchor="start" x="424.73" y="-3751.74" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="330.22" y="-3791.34" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="445.73" y="-3751.74" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="330.22" y="-3791.34" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dataset&#45;&#45;dataset_dag_run_queue -->
 <g id="edge25" class="edge">
 <title>dataset&#45;&#45;dataset_dag_run_queue</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M330.22,-3848.94C370.57,-3849.8 414.99,-3850.75 456.47,-3851.64"/>
-<text text-anchor="start" x="425.47" y="-3840.44" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="330.22" y="-3837.74" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="446.47" y="-3840.44" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="330.22" y="-3837.74" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dataset&#45;&#45;task_outlet_dataset_reference -->
 <g id="edge26" class="edge">
 <title>dataset&#45;&#45;task_outlet_dataset_reference</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M330.09,-3782.88C348.87,-3771.33 367.12,-3758.32 383,-3744 426.02,-3705.19 
413.49,-3675.37 456,-3636 459.47,-3632.78 463.08,-3629.63 466.8,-3626.55"/>
-<text text-anchor="start" x="435.8" y="-3615.35" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="330.09" y="-3771.68" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="456.8" y="-3615.35" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="330.09" y="-3771.68" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- dataset_event -->
 <g id="node29" class="node">
@@ -1367,8 +1367,8 @@
 <g id="edge27" class="edge">
 <title>dataset_event&#45;&#45;dagrun_dataset_event</title>
 <path fill="none" stroke="#7f7f7f" stroke-dasharray="5,2" 
d="M751.65,-1280.63C792.85,-1265.03 837.69,-1248.05 877.29,-1233.06"/>
-<text text-anchor="start" x="846.29" y="-1236.86" font-family="Times,serif" 
font-size="14.00">0..N</text>
-<text text-anchor="start" x="751.65" y="-1269.43" font-family="Times,serif" 
font-size="14.00">{0,1}</text>
+<text text-anchor="start" x="867.29" y="-1236.86" font-family="Times,serif" 
font-size="14.00">1</text>
+<text text-anchor="start" x="751.65" y="-1269.43" font-family="Times,serif" 
font-size="14.00">1</text>
 </g>
 <!-- import_error -->
 <g id="node30" class="node">
diff --git a/docs/apache-airflow/migrations-ref.rst 
b/docs/apache-airflow/migrations-ref.rst
index 08365cd250..2fdc682025 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                                                  |
 
+=================================+===================+===================+==============================================================+
-| ``98ae134e6fff`` (head)         | ``6abdffdd4815``  | ``2.6.0``         | 
Increase length of user identifier columns in ``ab_user``    |
+| ``937cbd173ca1`` (head)         | ``98ae134e6fff``  | ``2.7.0``         | 
Add index to task_instance table                             |
++---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
+| ``98ae134e6fff``                | ``6abdffdd4815``  | ``2.6.0``         | 
Increase length of user identifier columns in ``ab_user``    |
 |                                 |                   |                   | 
and ``ab_register_user`` tables                              |
 
+---------------------------------+-------------------+-------------------+--------------------------------------------------------------+
 | ``6abdffdd4815``                | ``290244fb8b83``  | ``2.6.0``         | 
add dttm index on log table                                  |
diff --git a/newsfragments/30762.improvement.rst 
b/newsfragments/30762.improvement.rst
new file mode 100644
index 0000000000..36aa3ca35b
--- /dev/null
+++ b/newsfragments/30762.improvement.rst
@@ -0,0 +1 @@
+PostgreSQL only improvement: Added index on taskinstance table. This index 
seems to have great positive effect in a setup with tens of millions such rows.

Reply via email to