[PR #1033] [CLOSED] Lazy criteria for ManyToMany collection #9069

Open
opened 2026-01-22 16:03:03 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/1033
Author: @bakura10
Created: 5/18/2014
Status: Closed

Base: old-prototype-3.xHead: many-to-many-lazy


📝 Commits (1)

📊 Changes

10 files changed (+231 additions, -19 deletions)

View changed files

📝 lib/Doctrine/ORM/Cache/Persister/AbstractCollectionPersister.php (+9 -2)
lib/Doctrine/ORM/LazyManyToManyCriteriaCollection.php (+109 -0)
📝 lib/Doctrine/ORM/PersistentCollection.php (+4 -2)
📝 lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php (+28 -1)
📝 lib/Doctrine/ORM/Persisters/CollectionPersister.php (+3 -2)
📝 lib/Doctrine/ORM/Persisters/ManyToManyPersister.php (+12 -3)
📝 lib/Doctrine/ORM/Persisters/OneToManyPersister.php (+7 -3)
📝 tests/Doctrine/Tests/Models/Quote/User.php (+3 -2)
📝 tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php (+48 -4)
📝 tests/Doctrine/Tests/OrmFunctionalTestCase.php (+8 -0)

📄 Description

This continues my previous work on making Criteria most efficient.

Currently we are wrapping matching calls on repositories and matching calls on EXTRA_LAZY associations around a LazyCriteria. However, ManyToMany are still completely loaded: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/PersistentCollection.php#L874

This is still problematic from a performance point of view because count, contains... cannot be optimized. I think the solution is similar to previous one, hence creating a Lazy collection for that kind of associations.

However, this is really tricky to do because of the whole mess inside the persisters (can't wait for them to be completely refactored, it's getting really hard to maintain this mess :p).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/1033 **Author:** [@bakura10](https://github.com/bakura10) **Created:** 5/18/2014 **Status:** ❌ Closed **Base:** `old-prototype-3.x` ← **Head:** `many-to-many-lazy` --- ### 📝 Commits (1) - [`46816ae`](https://github.com/doctrine/orm/commit/46816ae432486900c0f2ee4e837bf0e9b813a048) Initial support ### 📊 Changes **10 files changed** (+231 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/Cache/Persister/AbstractCollectionPersister.php` (+9 -2) ➕ `lib/Doctrine/ORM/LazyManyToManyCriteriaCollection.php` (+109 -0) 📝 `lib/Doctrine/ORM/PersistentCollection.php` (+4 -2) 📝 `lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php` (+28 -1) 📝 `lib/Doctrine/ORM/Persisters/CollectionPersister.php` (+3 -2) 📝 `lib/Doctrine/ORM/Persisters/ManyToManyPersister.php` (+12 -3) 📝 `lib/Doctrine/ORM/Persisters/OneToManyPersister.php` (+7 -3) 📝 `tests/Doctrine/Tests/Models/Quote/User.php` (+3 -2) 📝 `tests/Doctrine/Tests/ORM/Functional/PersistentCollectionCriteriaTest.php` (+48 -4) 📝 `tests/Doctrine/Tests/OrmFunctionalTestCase.php` (+8 -0) </details> ### 📄 Description This continues my previous work on making Criteria most efficient. Currently we are wrapping matching calls on repositories and matching calls on EXTRA_LAZY associations around a LazyCriteria. However, ManyToMany are still completely loaded: https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/PersistentCollection.php#L874 This is still problematic from a performance point of view because count, contains... cannot be optimized. I think the solution is similar to previous one, hence creating a Lazy collection for that kind of associations. However, this is really tricky to do because of the whole mess inside the persisters (can't wait for them to be completely refactored, it's getting really hard to maintain this mess :p). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:03:03 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9069