]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
remove lambda caching from loader strategies
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 16 Aug 2021 21:20:48 +0000 (17:20 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Aug 2021 18:17:00 +0000 (14:17 -0400)
commit1b5ae17384660e9153168d1250003b87da690542
treea4824e03c85f2bbe664a12a81335f6fec303e52d
parent76b506ed51e31b922014a30de2a5952d1a6ad891
remove lambda caching from loader strategies

Adjusted ORM loader internals to no longer use the "lambda caching" system
that was added in 1.4, as well as repaired one location that was still
using the previous "baked query" system for a query. The lambda caching
system remains an effective way to reduce the overhead of building up
queries that have relatively fixed usage patterns. In the case of loader
strategies, the queries used are responsible for moving through lots of
arbitrary options and criteria, which is both generated and sometimes
consumed by end-user code, that make the lambda cache concept not any more
efficient than not using it, at the cost of more complexity. In particular
the problems noted by :ticket:`6881` and :ticket:`6887` are made
considerably less complicated by removing this feature internally.

Fixed an issue where the :class:`_orm.Bundle` construct would not create
proper cache keys, leading to inefficient use of the query cache.  This
had some impact on the "selectinload" strategy and was identified as
part of :ticket:`6889`.

Added a Select._create_raw_select() method which essentially
performs ``__new__`` and then populates ``__dict__`` directly,
with no coercions.  This saves most of the overhead time that
the lambda caching system otherwise seeks to avoid.

Includes removal of bakedquery from
mapper->_subclass_load_via_in() which was overlooked from
the 1.4 refactor.

Fixes: #6079
Fixes: #6889
Change-Id: Ieac2d9d709b71ec4270e5c121fbac6ac870e2bb1
doc/build/changelog/unreleased_14/6889.rst [new file with mode: 0644]
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/loading.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/strategies.py
lib/sqlalchemy/orm/util.py
lib/sqlalchemy/sql/selectable.py
test/orm/test_cache_key.py
test/orm/test_subquery_relations.py