Create an index for "ports.network_id"
The method ``_port_filter_hook``, that is added in any "Port" SELECT command, filters the database "Port" registers by "network_id", using an exact match. This query speed will improve if this column is indexed in the database engine. Closes-Bug: #1973349 Change-Id: Ia20f96dc78ea04bb0ab4665e6d47a6365789d2c9
This commit is contained in:
parent
0f3f94d05a
commit
db2ae854cf
neutron/db
migration/alembic_migrations/versions
models_v2.py@ -1 +1 @@
|
||||
I43e0b669096
|
||||
4e6e655746f6
|
||||
|
34
neutron/db/migration/alembic_migrations/versions/zed/expand/4e6e655746f6_add_index_to_ports_network_id.py
Normal file
34
neutron/db/migration/alembic_migrations/versions/zed/expand/4e6e655746f6_add_index_to_ports_network_id.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Copyright 2022 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
from alembic import op
|
||||
|
||||
|
||||
"""add index to ports.network_id
|
||||
|
||||
Revision ID: 4e6e655746f6
|
||||
Revises: I43e0b669096
|
||||
Create Date: 2022-05-12 13:04:51.831792
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '4e6e655746f6'
|
||||
down_revision = 'I43e0b669096'
|
||||
|
||||
|
||||
def upgrade():
|
||||
index_name = 'ix_ports_network_id'
|
||||
op.create_index(index_name, 'ports', ['network_id'], unique=False)
|
@ -106,7 +106,7 @@ class Port(standard_attr.HasStandardAttributes, model_base.BASEV2,
|
||||
|
||||
name = sa.Column(sa.String(db_const.NAME_FIELD_SIZE))
|
||||
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
|
||||
nullable=False)
|
||||
nullable=False, index=True)
|
||||
fixed_ips = orm.relationship(IPAllocation,
|
||||
backref=orm.backref('port',
|
||||
load_on_pending=True),
|
||||
|
Loading…
x
Reference in New Issue
Block a user