]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
simplify relationship caching options
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Jun 2021 19:43:13 +0000 (15:43 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 9 Jun 2021 14:01:13 +0000 (10:01 -0400)
commitb8ff111975be2b8d2e370f51168e39c7fae44e92
tree2bc531c9be05614605d8b3ef527513c37d8044bd
parent5a0c700bb96bf2d80cfbf03f5ddfa97964987e4e
simplify relationship caching options

Clarified the current purpose of the
:paramref:`_orm.relationship.bake_queries` flag, which in 1.4 is to enable
or disable "lambda caching" of statements within the "lazyload" and
"selectinload" loader strategies; this is separate from the more
foundational SQL query cache that is used for most statements.
Additionally, the lazy loader no longer uses its own cache for many-to-one
SQL queries, which was an implementation quirk that doesn't exist for any
other loader scenario. Finally, the "lru cache" warning that the lazyloader
and selectinloader strategies could emit when handling a wide array of
class/relationship combinations has been removed; based on analysis of some
end-user cases, this warning doesn't suggest any significant issue. While
setting ``bake_queries=False`` for such a relationship will remove this
cache from being used, there's no particular performance gain in this case
as using no caching vs. using a cache that needs to refresh often likely
still wins out on the caching being used side.

Fixes: #6072
Fixes: #6487
Change-Id: Ida61f09b837d3acdafa07344d7d747d7f3ab226a
doc/build/changelog/unreleased_14/6072.rst [new file with mode: 0644]
lib/sqlalchemy/orm/relationships.py
lib/sqlalchemy/orm/strategies.py
test/aaa_profiling/test_orm.py
test/orm/test_cache_key.py
test/orm/test_subquery_relations.py