Add indexes to revision table

The commit and parent columns were not indexed, meaning that checking to see
if a commit's parent needed to be synced incurred a full table scan.  Add
indexes so it's faster.

Change-Id: I093f8265a655a1fe2b7ba1be792b87e6d701fec1
This commit is contained in:
James E. Blair 2015-03-10 16:32:59 -07:00
parent db9b6407b6
commit 461a0eee45
2 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,23 @@
"""add revision indexes
Revision ID: 1cdd4e2e74c
Revises: 4a802b741d2f
Create Date: 2015-03-10 16:17:41.330825
"""
# revision identifiers, used by Alembic.
revision = '1cdd4e2e74c'
down_revision = '4a802b741d2f'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_index(op.f('ix_revision_commit'), 'revision', ['commit'])
op.create_index(op.f('ix_revision_parent'), 'revision', ['parent'])
def downgrade():
pass

View File

@ -71,8 +71,8 @@ revision_table = Table(
Column('change_key', Integer, ForeignKey("change.key"), index=True),
Column('number', Integer, index=True, nullable=False),
Column('message', Text, nullable=False),
Column('commit', String(255), nullable=False),
Column('parent', String(255), nullable=False),
Column('commit', String(255), index=True, nullable=False),
Column('parent', String(255), index=True, nullable=False),
Column('fetch_auth', Boolean, nullable=False),
Column('fetch_ref', String(255), nullable=False),
Column('pending_message', Boolean, index=True, nullable=False),