Repository: incubator-airflow Updated Branches: refs/heads/master a59ba049c -> 7980f7771
[AIRFLOW-291] Add index for state in TI table Closes #1635 from aoen/ddavydov/add_index_to_task_instance_state Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/7980f777 Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/7980f777 Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/7980f777 Branch: refs/heads/master Commit: 7980f7771ab6b6f84259ea9a52e78e4f5f690e42 Parents: a59ba04 Author: Dan Davydov <[email protected]> Authored: Thu Jun 30 14:32:58 2016 -0700 Committer: Dan Davydov <[email protected]> Committed: Thu Jun 30 14:33:01 2016 -0700 ---------------------------------------------------------------------- .../versions/211e584da130_add_ti_state_index.py | 23 ++++++++++++++++++++ airflow/models.py | 1 + 2 files changed, 24 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/7980f777/airflow/migrations/versions/211e584da130_add_ti_state_index.py ---------------------------------------------------------------------- diff --git a/airflow/migrations/versions/211e584da130_add_ti_state_index.py b/airflow/migrations/versions/211e584da130_add_ti_state_index.py new file mode 100644 index 0000000..5991683 --- /dev/null +++ b/airflow/migrations/versions/211e584da130_add_ti_state_index.py @@ -0,0 +1,23 @@ +"""add TI state index + +Revision ID: 211e584da130 +Revises: 2e82aab8ef20 +Create Date: 2016-06-30 10:54:24.323588 + +""" + +# revision identifiers, used by Alembic. +revision = '211e584da130' +down_revision = '2e82aab8ef20' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.create_index('ti_state', 'task_instance', ['state'], unique=False) + +def downgrade(): + op.drop_index('ti_state', table_name='task_instance') http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/7980f777/airflow/models.py ---------------------------------------------------------------------- diff --git a/airflow/models.py b/airflow/models.py index 78e3d35..7e8ae50 100644 --- a/airflow/models.py +++ b/airflow/models.py @@ -715,6 +715,7 @@ class TaskInstance(Base): __table_args__ = ( Index('ti_dag_state', dag_id, state), + Index('ti_state', state), Index('ti_state_lkp', dag_id, task_id, execution_date, state), Index('ti_pool', pool, state, priority_weight), )
