Improve share list speed using lazy='subquery'
lazy='immediate' leads to each relationship being collected when
it is accessed. This results in at least three extra queries when
we query for all share details. lazy='subquery' collects all data
when the query is executed. In this commit we only changed code for
improving the share list with details ("manila list") speed.
Change-Id: Ia61b108ece0817069737980a614cc6c15c1a3507
Closes-Bug: #1859785
Co-authored-by: Johannes Kulik <johannes.kulik@sap.com>
Co-authored-by: Maurice Escher <maurice.escher@sap.com>
(cherry picked from commit 54c5667e6b
)
This commit is contained in:
parent
9c07eb3151
commit
f01e485578
@ -318,7 +318,7 @@ class Share(BASE, ManilaBase):
|
|||||||
task_state = Column(String(255))
|
task_state = Column(String(255))
|
||||||
instances = orm.relationship(
|
instances = orm.relationship(
|
||||||
"ShareInstance",
|
"ShareInstance",
|
||||||
lazy='immediate',
|
lazy='subquery',
|
||||||
primaryjoin=(
|
primaryjoin=(
|
||||||
'and_('
|
'and_('
|
||||||
'Share.id == ShareInstance.share_id, '
|
'Share.id == ShareInstance.share_id, '
|
||||||
@ -388,7 +388,7 @@ class ShareInstance(BASE, ManilaBase):
|
|||||||
nullable=True)
|
nullable=True)
|
||||||
_availability_zone = orm.relationship(
|
_availability_zone = orm.relationship(
|
||||||
"AvailabilityZone",
|
"AvailabilityZone",
|
||||||
lazy='immediate',
|
lazy='subquery',
|
||||||
foreign_keys=availability_zone_id,
|
foreign_keys=availability_zone_id,
|
||||||
primaryjoin=(
|
primaryjoin=(
|
||||||
'and_('
|
'and_('
|
||||||
@ -415,7 +415,7 @@ class ShareInstance(BASE, ManilaBase):
|
|||||||
nullable=True)
|
nullable=True)
|
||||||
share_type = orm.relationship(
|
share_type = orm.relationship(
|
||||||
"ShareTypes",
|
"ShareTypes",
|
||||||
lazy='immediate',
|
lazy='subquery',
|
||||||
foreign_keys=share_type_id,
|
foreign_keys=share_type_id,
|
||||||
primaryjoin='and_('
|
primaryjoin='and_('
|
||||||
'ShareInstance.share_type_id == ShareTypes.id, '
|
'ShareInstance.share_type_id == ShareTypes.id, '
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Improved share list speed using lazy='subquery'. The sqlalchemy models of
|
||||||
|
Share and Share Instance relationships previously had lazy='immediate'.
|
||||||
|
This resulted in at least three extra queries when we queried for all share
|
||||||
|
details.
|
Loading…
Reference in New Issue
Block a user