Skip to content

Commit c124ae6

Browse files
authored
improve ORM strategy changes (#8280)
1 parent 7f1f801 commit c124ae6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/en/appendices/5-4-migration-guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ version is reported as `unknown`), the header is omitted.
4444
- The default eager loading strategy for `HasMany` and `BelongsToMany` associations
4545
has changed from `select` to `subquery`. If you need the previous behavior,
4646
explicitly set `'strategy' => 'select'` when defining associations.
47+
See [Associations](../orm/associations#has-many-associations) for more details.
4748

4849
### Controller
4950

docs/en/orm/associations.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,12 @@ Possible keys for hasMany association arrays include:
462462
- **propertyName**: The property name that should be filled with data from the
463463
associated table into the source table results. By default, this is the
464464
underscored & plural name of the association so `comments` in our example.
465-
- **strategy**: Defines the query strategy to use. Defaults to 'subquery'. The
466-
other valid value is 'select', which uses the `IN` list of parent keys
465+
- **strategy**: Defines the query strategy to use. Defaults to `subquery`. The
466+
other valid value is `select`, which uses the `IN` list of parent keys
467467
directly instead of a subquery.
468+
::: tip New default strategy in version 5.4+
469+
The default strategy has changed from `select` to `subquery` in order to improve performance when the number of parent keys is large.
470+
:::
468471
- **saveStrategy**: Either `append` or `replace`. Defaults to `append`. When `append` the current
469472
records are appended to any records in the database. When `replace` associated
470473
records not in the current set will be removed. If the foreign key is a nullable
@@ -616,9 +619,12 @@ Possible keys for belongsToMany association arrays include:
616619
- **propertyName**: The property name that should be filled with data from the
617620
associated table into the source table results. By default, this is the
618621
underscored & plural name of the association, so `tags` in our example.
619-
- **strategy**: Defines the query strategy to use. Defaults to 'subquery'. The
620-
other valid value is 'select', which uses the `IN` list of parent keys
622+
- **strategy**: Defines the query strategy to use. Defaults to `subquery`. The
623+
other valid value is `select`, which uses the `IN` list of parent keys
621624
directly instead of a subquery.
625+
::: tip New default strategy in version 5.4+
626+
The default strategy has changed from `select` to `subquery` in order to improve performance when the number of parent keys is large.
627+
:::
622628
- **saveStrategy**: Either `append` or `replace`. Defaults to `replace`.
623629
Indicates the mode to be used for saving associated entities. The former will
624630
only create new links between both side of the relation and the latter will

0 commit comments

Comments
 (0)