add an index for the story_storytags table

Queries that look for stories with tags take significant amount of
time without this change. One trivial query for active stories with
one tag dropped from 7m19s to 2.7s.

Story: #2001939
Task: #15055
Change-Id: Id1783a3cf355f11b2037f4e0ada9514993820bca
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-06-25 17:18:34 -04:00
parent 17117d45cc
commit 973696b0c5
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
# Licensed 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.
#
"""index story_storytags
Revision ID: a6e048164572
Revises: 062
Create Date: 2018-06-25 17:13:43.992561
"""
# revision identifiers, used by Alembic.
revision = '063'
down_revision = '062'
from alembic import op
def upgrade(active_plugins=None, options=None):
op.create_index('story_storytags_idx',
'story_storytags', ['story_id'])
def downgrade(active_plugins=None, options=None):
op.drop_index('story_storytags_idx')