Indexes added on action_logs.body
For increasing speed of creating clusters report indexes on body->>'action_name' and body->>'action_type' were added. Query execution plan cost was optimized from 21000 to 60. Collector base DB test fixed. Alembic constant 'base' used for downgrade all alembic migrations instead of current revisions number calculation. Change-Id: Ief06aa9bbb94ebad2c2791617df8fb96cf979118 Closes-Bug: #1488092
This commit is contained in:
parent
c85d77549f
commit
2419e947b6
|
@ -0,0 +1,43 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Indexes on action_logs.body
|
||||
|
||||
Revision ID: 278885b460cd
|
||||
Revises: 567ac5955ca3
|
||||
Create Date: 2015-08-24 14:45:03.193144
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '278885b460cd'
|
||||
down_revision = '567ac5955ca3'
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("CREATE INDEX action_logs_body_action_type ON "
|
||||
"action_logs ((body->>'action_type'))")
|
||||
op.execute("CREATE INDEX action_logs_body_action_name ON "
|
||||
"action_logs ((body->>'action_name'))")
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("DROP INDEX action_logs_body_action_name")
|
||||
op.execute("DROP INDEX action_logs_body_action_type")
|
||||
### end Alembic commands ###
|
|
@ -15,7 +15,6 @@
|
|||
from alembic.util import CommandError
|
||||
from flask import json
|
||||
import flask_migrate
|
||||
import glob
|
||||
import os
|
||||
from unittest2.case import TestCase
|
||||
|
||||
|
@ -68,10 +67,6 @@ class BaseTest(TestCase):
|
|||
|
||||
class DbTest(BaseTest):
|
||||
|
||||
def _get_number_of_migrations(self, migr_directory):
|
||||
migr_files_path = os.path.join(migr_directory, 'versions', '*.py')
|
||||
return len(glob.glob(migr_files_path))
|
||||
|
||||
def setUp(self):
|
||||
super(DbTest, self).setUp()
|
||||
|
||||
|
@ -81,12 +76,10 @@ class DbTest(BaseTest):
|
|||
# Cleaning DB. It useful in case of tests failure
|
||||
directory = os.path.join(os.path.dirname(__file__),
|
||||
'..', 'api', 'db', 'migrations')
|
||||
self._get_number_of_migrations(directory)
|
||||
revision = '-{0}'.format(self._get_number_of_migrations(directory))
|
||||
with app.app_context():
|
||||
try:
|
||||
flask_migrate.downgrade(directory=directory,
|
||||
revision=revision)
|
||||
revision='base')
|
||||
except CommandError:
|
||||
# Workaround for the first migration
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue