Skip to content

Commit e44e1dc

Browse files
authored
readme: add comparision table (#9)
* fix tests compatibility with Doctrine 3.3.0 which reenabled partial * readme: add comparision table * readme: merge comparison sections * improve comparison table * add emoji colors to comparsion table * readme: use ascii * readme: add links to slides * readme: update comparision table to reflect that partial is supported again
1 parent 4d739a4 commit e44e1dc

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,32 @@
22

33
`shipmonk/doctrine-entity-preloader` is a PHP library designed to tackle the n+1 query problem in Doctrine ORM by efficiently preloading related entities. This library offers a flexible and powerful way to optimize database access patterns, especially in cases with complex entity relationships.
44

5-
- 🚀 **Performance Boost:** Minimizes n+1 issues by preloading related entities with **constant number of queries**.
6-
- 🔄 **Flexible:** Supports all associations: `#[OneToOne]`, `#[OneToMany]`, `#[ManyToOne]`, and `#[ManyToMany]`.
7-
- 💡 **Easy Integration:** Simple to integrate with your existing Doctrine setup.
5+
- :rocket: **Performance Boost:** Minimizes n+1 issues by preloading related entities with **constant number of queries**.
6+
- :arrows_counterclockwise: **Flexible:** Supports all associations: `#[OneToOne]`, `#[OneToMany]`, `#[ManyToOne]`, and `#[ManyToMany]`.
7+
- :bulb: **Easy Integration:** Simple to integrate with your existing Doctrine setup.
8+
9+
10+
## Comparison
11+
12+
| | [Default](https://docs.google.com/presentation/d/1sSlZOxmEUVKt0l8zhimex-6lR0ilC001GXh8colaXxg/edit#slide=id.g30998e74a82_0_0) | [Manual Preload](https://docs.google.com/presentation/d/1sSlZOxmEUVKt0l8zhimex-6lR0ilC001GXh8colaXxg/edit#slide=id.g309b68062f4_0_0) | [Fetch Join](https://docs.google.com/presentation/d/1sSlZOxmEUVKt0l8zhimex-6lR0ilC001GXh8colaXxg/edit#slide=id.g309b68062f4_0_15) | [setFetchMode](https://docs.google.com/presentation/d/1sSlZOxmEUVKt0l8zhimex-6lR0ilC001GXh8colaXxg/edit#slide=id.g309b68062f4_0_35) | [**EntityPreloader**](https://docs.google.com/presentation/d/1sSlZOxmEUVKt0l8zhimex-6lR0ilC001GXh8colaXxg/edit#slide=id.g309b68062f4_0_265) |
13+
|------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
14+
| [OneToMany](tests/EntityPreloadBlogOneHasManyTest.php) | :red_circle: 1 + n | :green_circle: 1 + 1 | :orange_circle: 1, but duplicates rows | :green_circle: 1 + 1 | :green_circle: 1 + 1 |
15+
| [OneToManyDeep](tests/EntityPreloadBlogOneHasManyDeepTest.php) | :red_circle: 1 + n + n² | :green_circle: 1 + 1 + 1 | :orange_circle: 1, but duplicates rows | :red_circle: 1 + 1 + n² | :green_circle: 1 + 1 + 1 |
16+
| [OneToManyAbstract](tests/EntityPreloadBlogOneHasManyAbstractTest.php) | :red_circle: 1 + n + n² | :orange_circle: 1 + 1 + 1, but duplicates rows | :orange_circle: 1, but duplicates rows | :red_circle: 1 + 1 + n² | :orange_circle: 1 + 1 + 1, but duplicates rows |
17+
| [ManyToOne](tests/EntityPreloadBlogManyHasOneTest.php) | :red_circle: 1 + n | :green_circle: 1 + 1 | :orange_circle: 1, but duplicates rows | :green_circle: 1 + 1 | :green_circle: 1 + 1 |
18+
| [ManyToOneDeep](tests/EntityPreloadBlogManyHasOneDeepTest.php) | :red_circle: 1 + n + n | :green_circle: 1 + 1 + 1 | :orange_circle: 1, but duplicates rows | :red_circle: 1 + 1 + n | :green_circle: 1 + 1 + 1 |
19+
| [ManyToMany](tests/EntityPreloadBlogManyHasManyTest.php) | :red_circle: 1 + n | :green_circle: 1 + 1 | :orange_circle: 1, but duplicates rows | :red_circle: 1 + n | :green_circle: 1 + 1 |
20+
21+
Unlike manual preload does not require writing custom queries for each association.
22+
23+
Unlike fetch joins, the EntityPreloader does not fetches duplicate data, which slows down both the query and the hydration process, except when necessary to prevent additional queries fired by Doctrine during hydration process.
24+
25+
Unlike `Doctrine\ORM\AbstractQuery::setFetchMode` it can
26+
27+
* preload nested associations
28+
* preload `#[ManyToMany]` association
29+
* avoid additional queries fired by Doctrine during hydration process
30+
831

932
## Installation
1033

@@ -44,18 +67,6 @@ foreach ($categories as $category) {
4467
}
4568
```
4669

47-
## Comparison vs. Fetch Joins
48-
49-
Unlike fetch joins, the EntityPreloader does not fetches duplicate data, which slows down both the query and the hydration process, except when necessary to prevent additional queries fired by Doctrine during hydration process.
50-
51-
## Comparison vs. `Doctrine\ORM\AbstractQuery::setFetchMode`
52-
53-
Unlike `setFetchMode` it can
54-
55-
* preload nested associations
56-
* preload `#[ManyToMany]` association
57-
* avoid additional queries fired by Doctrine during hydration process
58-
5970
## Configuration
6071

6172
`EntityPreloader` allows you to adjust batch sizes and fetch join limits to fit your application's performance needs:

0 commit comments

Comments
 (0)