Add some missing indexes that should make queries significantly faster

This commit is contained in:
Joseph Schorr 2019-02-14 17:21:01 -05:00
parent ea9707b969
commit 331a7a640b
3 changed files with 68 additions and 3 deletions

View file

@ -0,0 +1,32 @@
"""Add lifetime end indexes to tag tables
Revision ID: b9045731c4de
Revises: e184af42242d
Create Date: 2019-02-14 17:18:40.474310
"""
# revision identifiers, used by Alembic.
revision = 'b9045731c4de'
down_revision = 'e184af42242d'
from alembic import op
def upgrade(tables, tester):
# ### commands auto generated by Alembic - please adjust! ###
op.create_index('repositorytag_repository_id_lifetime_end_ts', 'repositorytag', ['repository_id', 'lifetime_end_ts'], unique=False)
op.create_index('tag_repository_id_lifetime_end_ms', 'tag', ['repository_id', 'lifetime_end_ms'], unique=False)
op.create_index('repositorytag_repository_id_lifetime_start_ts', 'repositorytag', ['repository_id', 'lifetime_start_ts'], unique=False)
op.create_index('tag_repository_id_lifetime_start_ms', 'tag', ['repository_id', 'lifetime_start_ms'], unique=False)
# ### end Alembic commands ###
def downgrade(tables, tester):
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('tag_repository_id_lifetime_end_ms', table_name='tag')
op.drop_index('repositorytag_repository_id_lifetime_end_ts', table_name='repositorytag')
op.drop_index('tag_repository_id_lifetime_start_ms', table_name='tag')
op.drop_index('repositorytag_repository_id_lifetime_start_ts', table_name='repositorytag')
# ### end Alembic commands ###

View file

@ -0,0 +1,28 @@
"""Add missing index on UUID fields
Revision ID: e184af42242d
Revises: 6ec8726c0ace
Create Date: 2019-02-14 16:35:47.768086
"""
# revision identifiers, used by Alembic.
revision = 'e184af42242d'
down_revision = '6ec8726c0ace'
from alembic import op
def upgrade(tables, tester):
# ### commands auto generated by Alembic - please adjust! ###
op.create_index('permissionprototype_uuid', 'permissionprototype', ['uuid'], unique=False)
op.create_index('repositorybuildtrigger_uuid', 'repositorybuildtrigger', ['uuid'], unique=False)
op.create_index('user_uuid', 'user', ['uuid'], unique=False)
# ### end Alembic commands ###
def downgrade(tables, tester):
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('user_uuid', table_name='user')
op.drop_index('repositorybuildtrigger_uuid', table_name='repositorybuildtrigger')
op.drop_index('permissionprototype_uuid', table_name='permissionprototype')
# ### end Alembic commands ###