mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10917] Got rid of redundant JOINs/WHEREs of WhereInWalker #12696
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?
Original Pull Request: https://github.com/doctrine/orm/pull/10917
State: closed
Merged: No
Doctrine\ORM\Tools\Pagination\Paginatoris an amazing tool that lets you fetch entities in chunks. And it sends two separate SQL queries:For simplicity let's call them id and data queries.
To demonstrate it, lets use CmsUser and CmsAddress entities:
The code above will trigger two SQL queries:
id
data
The problem is that the data query has:
INNER JOIN cms_addresses c1_c1_.city = ?This PR tries to optimize the data query.
Basically, this PR does the following:
JOINs are skipped for the data query if not any join is used inSELECT,GROUP BY, orORDER BYclauses. It is done only if theHAVINGclause is not specified (simplicity is the main reason, and it can be optimized in the future).I want to clarify that the EasyAdmin
createIndexQueryBuildertriggered this PR, and all the index actions in EasyAdmin should benefit from it.