Fix share type model scalability for get request
"share type list" operation greatly depends on amount of records in "shares" table. It leads to big slowness of just requesting list of several records of share types. That can take dozens of seconds. Main reason for it lays in usage of redundant "relationship" of "share types" table to "shares" table. It is not used in Manila, so remove it. Change-Id: I463b12e2eb7249b42835be063cd953b56ee7376d Closes-Bug: #1506240
This commit is contained in:
parent
cd4f0ef569
commit
f1ada3fe97
@ -2653,7 +2653,7 @@ def _share_type_get_query(context, session=None, read_deleted=None,
|
||||
models.ShareTypes,
|
||||
session=session,
|
||||
read_deleted=read_deleted). \
|
||||
options(joinedload('extra_specs')).options(joinedload('shares'))
|
||||
options(joinedload('extra_specs'))
|
||||
|
||||
if 'projects' in expected_fields:
|
||||
query = query.options(joinedload('projects'))
|
||||
@ -2722,7 +2722,6 @@ def _share_type_get(context, id, session=None, inactive=False,
|
||||
result = _share_type_get_query(
|
||||
context, session, read_deleted, expected_fields). \
|
||||
filter_by(id=id). \
|
||||
options(joinedload('shares')). \
|
||||
first()
|
||||
|
||||
if not result:
|
||||
@ -2750,7 +2749,6 @@ def _share_type_get_by_name(context, name, session=None):
|
||||
result = model_query(context, models.ShareTypes, session=session).\
|
||||
options(joinedload('extra_specs')).\
|
||||
filter_by(name=name).\
|
||||
options(joinedload('shares')).\
|
||||
first()
|
||||
|
||||
if not result:
|
||||
|
@ -278,6 +278,13 @@ class Share(BASE, ManilaBase):
|
||||
viewonly=True,
|
||||
join_depth=2,
|
||||
)
|
||||
share_type = orm.relationship(
|
||||
"ShareTypes",
|
||||
lazy=True,
|
||||
foreign_keys=share_type_id,
|
||||
primaryjoin='and_('
|
||||
'Share.share_type_id == ShareTypes.id, '
|
||||
'ShareTypes.deleted == "False")')
|
||||
|
||||
|
||||
class ShareInstance(BASE, ManilaBase):
|
||||
@ -365,13 +372,6 @@ class ShareTypes(BASE, ManilaBase):
|
||||
deleted = Column(String(36), default='False')
|
||||
name = Column(String(255))
|
||||
is_public = Column(Boolean, default=True)
|
||||
shares = orm.relationship(Share,
|
||||
backref=orm.backref('share_type',
|
||||
uselist=False),
|
||||
foreign_keys=id,
|
||||
primaryjoin='and_('
|
||||
'Share.share_type_id == ShareTypes.id, '
|
||||
'ShareTypes.deleted == "False")')
|
||||
|
||||
|
||||
class ShareTypeProjects(BASE, ManilaBase):
|
||||
|
Loading…
Reference in New Issue
Block a user