]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Don't use a query for watch_rule_get()
authorZane Bitter <zbitter@redhat.com>
Mon, 2 Sep 2013 14:02:14 +0000 (16:02 +0200)
committerZane Bitter <zbitter@redhat.com>
Mon, 2 Sep 2013 14:07:21 +0000 (16:07 +0200)
When getting a database record by ID, it is much more efficient to get() it
directly than to perform a query or the database to obtain the ID (again)
and then get it.

Change-Id: I89b46d698c033e54ee9a50172ccad3eb3833cb1e

heat/db/sqlalchemy/api.py

index dd1716f27ae6501f30724df5eab66477210f0474..4c1ac228d5a7bea2ed783a49a9c23b319857cdbe 100644 (file)
@@ -315,8 +315,7 @@ def event_create(context, values):
 
 
 def watch_rule_get(context, watch_rule_id):
-    result = model_query(context, models.WatchRule).\
-        filter_by(id=watch_rule_id).first()
+    result = model_query(context, models.WatchRule).get(watch_rule_id)
     return result