]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Dont eager load volume type specs on volume list
authorCory Stone <corystone@gmail.com>
Wed, 26 Aug 2015 00:05:36 +0000 (19:05 -0500)
committerCory Stone <corystone@gmail.com>
Wed, 26 Aug 2015 00:05:36 +0000 (19:05 -0500)
Some drivers need extra specs loaded on create and the session could be
closed by the time they access them. However for a volume list, eager
loading these attributes causes a severe performance penalty.

Move the eager load to the single volume get case.

Change-Id: I6fbf5508684a01a7df7930d4f1b4a47adeefe521
Closes-Bug: 1486289

cinder/db/sqlalchemy/api.py

index 868909892e50a5662292f8dd2d5eace7d4dd1892..c356c5cc21ac611e9f9975fa5227ca769235a1a4 100644 (file)
@@ -1296,7 +1296,6 @@ def _volume_get_query(context, session=None, project_only=False):
             options(joinedload('volume_metadata')).\
             options(joinedload('volume_admin_metadata')).\
             options(joinedload('volume_type')).\
-            options(joinedload('volume_type.extra_specs')).\
             options(joinedload('volume_attachment')).\
             options(joinedload('consistencygroup'))
     else:
@@ -1304,7 +1303,6 @@ def _volume_get_query(context, session=None, project_only=False):
                            project_only=project_only).\
             options(joinedload('volume_metadata')).\
             options(joinedload('volume_type')).\
-            options(joinedload('volume_type.extra_specs')).\
             options(joinedload('volume_attachment')).\
             options(joinedload('consistencygroup'))
 
@@ -1312,6 +1310,7 @@ def _volume_get_query(context, session=None, project_only=False):
 @require_context
 def _volume_get(context, volume_id, session=None):
     result = _volume_get_query(context, session=session, project_only=True).\
+        options(joinedload('volume_type.extra_specs')).\
         filter_by(id=volume_id).\
         first()