]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Optimize out JOIN for selectinload with many to one
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Jul 2019 17:05:06 +0000 (13:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Jul 2019 21:56:07 +0000 (17:56 -0400)
commit5f72a69e9f857a45b846f515a8e322e5b90c1e53
treecf564cd9d599555537940fe03971dc2bdf744387
parentec1dce7849584f2cad136957abf6e4d9bac7b68b
Optimize out JOIN for selectinload with many to one

The optimzation applied to selectin loading in :ticket:`4340` where a JOIN
is not needed to eagerly load related items is now applied to many-to-one
relationships as well, so that only the related table is queried for a
simple join condition.   In this case, the related items are queried
based on the value of a foreign key column on the parent; if these columns
are deferred or otherwise not loaded on any of the parent objects in
the collection, the loader falls back to the JOIN method.

Fixes: #4775
Change-Id: I398e0d276789ce6e0019d213a37bdf99d24ec290
(cherry picked from commit a5a66f1e580150a55a729e7b6dc804adb55b2f5c)
doc/build/changelog/unreleased_13/4775.rst [new file with mode: 0644]
doc/build/orm/loading_relationships.rst
lib/sqlalchemy/orm/strategies.py
test/orm/test_selectin_relations.py