summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/interfaces.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-04-07 14:18:22 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2017-04-13 14:22:59 -0400
commitb7644319e85ce38c1a576802317a9058a6aed82d (patch)
tree12db3074d79d0c54deb247a7e79424312e183cf3 /lib/sqlalchemy/orm/interfaces.py
parent755da1797432ee98dd3d1d309026a21529b45f75 (diff)
downloadsqlalchemy-b7644319e85ce38c1a576802317a9058a6aed82d.tar.gz
Use baked lazyloading by default
The ``lazy="select"`` loader strategy now makes used of the :class:`.BakedQuery` query caching system in all cases. This removes most overhead of generating a :class:`.Query` object and running it into a :func:`.select` and then string SQL statement from the process of lazy-loading related collections and objects. The "baked" lazy loader has also been improved such that it can now cache in most cases where query load options are used. Change-Id: Ic96792fffaa045ae9aa0a4657d6d29235d3efb85 Fixes: #3954
Diffstat (limited to 'lib/sqlalchemy/orm/interfaces.py')
-rw-r--r--lib/sqlalchemy/orm/interfaces.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 1b14acefb..84b5f6cc7 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -593,6 +593,28 @@ class MapperOption(object):
self.process_query(query)
+ def _generate_cache_key(self, path):
+ """Used by the baked loader to see if this option can be cached.
+
+ A given MapperOption that returns a cache key must return a key
+ that uniquely identifies the complete state of this option, which
+ will match any other MapperOption that itself retains the identical
+ state. This includes path options, flags, etc.
+
+ If the MapperOption does not apply to the given path and would
+ not affect query results on such a path, it should return None.
+
+ if the MapperOption **does** apply to the give path, however cannot
+ produce a safe cache key, it should return False; this will cancel
+ caching of the result. An unsafe cache key is one that includes
+ an ad-hoc user object, typically an AliasedClass object. As these
+ are usually created per-query, they don't work as cache keys.
+
+
+ """
+
+ return None
+
class LoaderStrategy(object):
"""Describe the loading behavior of a StrategizedProperty object.