diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-05-25 22:36:44 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-05-28 14:38:56 -0400 |
| commit | 77f1b7d236dba6b1c859bb428ef32d118ec372e6 (patch) | |
| tree | 7fae8eaaf303d6ce02bd423abf216550001e2f7b /lib/sqlalchemy/util | |
| parent | 366e88ea0e5c5417184c1dd4776cff752560631d (diff) | |
| download | sqlalchemy-77f1b7d236dba6b1c859bb428ef32d118ec372e6.tar.gz | |
callcount reductions and refinement for cached queries
This commit includes that we've removed the "_orm_query"
attribute from compile state as well as query context.
The attribute created reference cycles and also added
method call overhead. As part of this change,
the interface for ORMExecuteState changes a bit, as well
as the interface for the horizontal sharding extension
which now deprecates the "query_chooser" callable
in favor of "execute_chooser", which receives the contextual
object. This will also work more nicely when we implement
the new execution path for bulk updates and deletes.
Pre-merge execution options for statement, connection,
arguments all up front in Connection. that way they
can be passed to the before_execute / after_execute events,
and the ExecutionContext doesn't have to merge as second
time. Core execute is pretty close to 1.3 now.
baked wasn't using the new one()/first()/one_or_none() methods,
fixed that.
Convert non-buffered cursor strategy to be a stateless
singleton. inline all the paths by which the strategy
gets chosen, oracle and SQL Server dialects make use of the
already-invoked post_exec() hook to establish the alternate
strategies, and this is actually much nicer than it was before.
Add caching to mapper instance processor for getters.
Identified a reference cycle per query that was showing
up as a lot of gc cleanup, fixed that.
After all that, performance not budging much. Even
test_baked_query now runs with significantly fewer function
calls than 1.3, still 40% slower.
Basically something about the new patterns just makes
this slower and while I've walked a whole bunch of them
back, it hardly makes a dent. that said, the performance
issues are relatively small, in the 20-40% time increase
range, and the new caching feature
does provide for regular ORM and Core queries that
are cached, and they are faster than non-cached.
Change-Id: I7b0b0d8ca550c05f79e82f75cd8eff0bbfade053
Diffstat (limited to 'lib/sqlalchemy/util')
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index f6fefc244..52debc517 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -942,6 +942,10 @@ class HasMemoized(object): for elem in self._memoized_keys: assert elem not in self.__dict__ + def _set_memoized_attribute(self, key, value): + self.__dict__[key] = value + self._memoized_keys |= {key} + class memoized_attribute(object): """A read-only @property that is only evaluated once.""" @@ -1260,15 +1264,20 @@ class classproperty(property): class hybridproperty(object): def __init__(self, func): self.func = func + self.clslevel = func def __get__(self, instance, owner): if instance is None: - clsval = self.func(owner) + clsval = self.clslevel(owner) clsval.__doc__ = self.func.__doc__ return clsval else: return self.func(instance) + def classlevel(self, func): + self.clslevel = func + return self + class hybridmethod(object): """Decorate a function as cls- or instance- level.""" |
