]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
ensure anon_map is passed for most annotated traversals
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 10 Nov 2022 22:01:58 +0000 (17:01 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Nov 2022 20:25:35 +0000 (15:25 -0500)
commit1d8833a9c1ada64cfc716109a8836b32cb8a9bd6
treeae5d2f6adfb578c43603b0141c27fad520c70e4f
parente3a8d198917f4246365e09fa975d55c64082cd2e
ensure anon_map is passed for most annotated traversals

We can cache the annotated cache key for Table, but
for selectables it's not safe, as it fails to pass the
anon_map along and creates many redudant structures in
observed test scenario.  It is likely safe for a
Column that's mapped to a Table also, however this is
not implemented here.   Will have to see if that part
needs adjusting.

Fixed critical memory issue identified in cache key generation, where for
very large and complex ORM statements that make use of lots of ORM aliases
with subqueries, cache key generation could produce excessively large keys
that were orders of magnitude bigger than the statement itself. Much thanks
to Rollo Konig Brock for their very patient, long term help in finally
identifying this issue.

Also within TypeEngine objects, when we generate elements
for instance variables, skip the None elements at least.
this also saves on tuple complexity.

Fixes: #8790
Change-Id: I448ddbfb45ae0a648815be8dad4faad7d1977427
12 files changed:
doc/build/changelog/unreleased_14/8790.rst [new file with mode: 0644]
lib/sqlalchemy/sql/annotation.py
lib/sqlalchemy/sql/cache_key.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/sql/type_api.py
lib/sqlalchemy/testing/__init__.py
lib/sqlalchemy/testing/assertions.py
lib/sqlalchemy/testing/util.py
lib/sqlalchemy/util/__init__.py
lib/sqlalchemy/util/compat.py
test/orm/test_cache_key.py