]> review.fuel-infra Code Review - openstack-build/heat-build.git/commit
Optimise DB lookups by ID
authorZane Bitter <zbitter@redhat.com>
Thu, 5 Jul 2012 12:12:46 +0000 (14:12 +0200)
committerZane Bitter <zbitter@redhat.com>
Wed, 11 Jul 2012 15:54:36 +0000 (11:54 -0400)
commit8108c0aefb316516061a3db6ae44180b2c26b4d7
tree09e333acd99823f409e46fec0551b6fbc3bf5854
parent5737782c718e84446d8f7f207b3b488ca4473862
Optimise DB lookups by ID

SQLAlchemy caches objects in the database per-session, but cannot cache
queries. A query just generates a list of object primary keys, which is
then used to fetch the corresponding objects from the cache (if possible)
or database. Therefore a query which filters by primary key is a waste of
time, since it just returns (surprise!) the key we started off with. If we
have the primary key (in this case the id field), just look up the object.

Change-Id: I7123c12372b26c0e1b91b2496921c54d9d992cd8
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/db/sqlalchemy/api.py