diff options
author | Thomas Herve <therve@redhat.com> | 2016-10-18 21:37:49 +0200 |
---|---|---|
committer | Thomas Herve <therve@redhat.com> | 2016-10-18 21:37:49 +0200 |
commit | c59865870bc8cdd9dbdbaace11b5a0af48f93130 (patch) | |
tree | bf0df870f7b7c0409bf5bb1dce6f3887e46683a2 /heat/objects | |
parent | 90372215e520fccff9807fdacd08c8a11d570b62 (diff) | |
download | heat-c59865870bc8cdd9dbdbaace11b5a0af48f93130.tar.gz |
Don't query raw_template in stacks uselessly
When partially removing eager loading of raw_template in stacks
(260b79ed28b5dc48f70fe77dfdfc074991ad1e99), we didn't get into account
that accessing the sqlalchemy field would create an additional query
whereas it was previously eager loaded. This removes it by only filling
the field when it's already fetched.
Change-Id: Ifa17c74e3559adaef56593a205101d92e9a37da5
Closes-Bug: #1634127
Diffstat (limited to 'heat/objects')
-rw-r--r-- | heat/objects/stack.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/heat/objects/stack.py b/heat/objects/stack.py index 9f34616c1..1de7d5b11 100644 --- a/heat/objects/stack.py +++ b/heat/objects/stack.py @@ -66,11 +66,15 @@ class Stack( def _from_db_object(context, stack, db_stack): for field in stack.fields: if field == 'raw_template': - stack['raw_template'] = ( - raw_template.RawTemplate.from_db_object( - context, - raw_template.RawTemplate(), - db_stack['raw_template'])) + raw_template_obj = db_stack.__dict__.get('raw_template') + if raw_template_obj is not None: + # Object is already lazy loaded + raw_template_obj = ( + raw_template.RawTemplate.from_db_object( + context, + raw_template.RawTemplate(), + raw_template_obj)) + stack['raw_template'] = raw_template_obj else: stack[field] = db_stack.__dict__.get(field) stack._context = context |