Skip to content

Commit

Permalink
[AIRFLOW-291] Add index for state in TI table
Browse files Browse the repository at this point in the history
Closes apache#1635 from aoen/ddavydov/add_index_to_task_instance_state
  • Loading branch information
aoen committed Jun 30, 2016
1 parent a59ba04 commit 7980f77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions airflow/migrations/versions/211e584da130_add_ti_state_index.py
Original file line number Diff line number Diff line change
@@ -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')
1 change: 1 addition & 0 deletions airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down

0 comments on commit 7980f77

Please sign in to comment.