mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-1656: fetch mode EXTRA_LAZY does not do a IN(1, 2, 3, ...) merge type query to fetch OneToMany results #2080
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Feb 17, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user des.hymers:
Using the fetch mode EXTRA_LAZY does not produce a SQL query to fetch all OneToMany relationship results via a IN(1, 2, 3, ...) type merged query, instead it does one query per row in the result set.
First query to obtain all the pages
SELECT t0.page_id AS page_id1, t0.name AS name2, t0.text AS text3, t0.url AS url4, t0.revision_id AS revision_id5, t0.owner_id AS owner_id6, t0.is_active AS is_active7 FROM pages t0
then for each row in that result set
SELECT t0.attribute_id AS attribute_id1, t0.page_id AS page_id2, t0.key AS key3, t0.value AS value4, t0.page_id AS page_id5 FROM page_attributes t0 WHERE t0.page_id = ?
What is desired is a query like this,
SELECT t0.attribute_id AS attribute_id1, t0.page_id AS page_id2, t0.key AS key3, t0.value AS value4, t0.page_id AS page_id5 FROM page_attributes t0 WHERE t0.page_id IN(1, 2, 3, ...)
to obtain all the attributes for the pages, after the first original page query.
@doctrinebot commented on GitHub (Feb 17, 2012):
Comment created by des.hymers:
had a typo in the file I uploaded, corrected now
@doctrinebot commented on GitHub (Feb 17, 2012):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Feb 17, 2012):
Comment created by @asm89:
Closed as invalid, because this is the ORM working as intended. First all the PageEntity objects are loaded. Next there is a loop over all the objects, with an inner loop on the "attributes" association. These attributes are lazy loaded for each individual page, hence 1 query for all the pages and n queries for all the attributes of the pages.
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 2 attachments from Jira into https://gist.github.com/16d842e82e39d51e9e98