Skip to content

Commit d7f9e4f

Browse files
committed
docs: clarify chunking caveats
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
1 parent 9b8e8b1 commit d7f9e4f

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎user_guide_src/source/models/model.rst‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,8 @@ Sometimes, you need to process large amounts of data and would run the risk of r
10571057
This is best used during cronjobs, data exports, or other large tasks. To make this simpler, you can
10581058
process the data in smaller, manageable pieces using the methods below.
10591059

1060+
.. note:: The ``chunk()``, ``chunkRows()``, ``chunkById()``, and ``chunkRowsById()`` methods do not trigger Model callbacks.
1061+
10601062
chunk()
10611063
-------
10621064

@@ -1084,7 +1086,7 @@ If you need to update or delete rows while processing them, use ``chunkById()``.
10841086
This method retrieves each chunk ordered by the model's primary key instead of using an offset,
10851087
so deleting or updating rows already processed will not cause later rows to be skipped.
10861088

1087-
.. literalinclude:: model/069.php
1089+
.. literalinclude:: model/071.php
10881090

10891091
chunkRowsById()
10901092
---------------
@@ -1093,11 +1095,12 @@ chunkRowsById()
10931095

10941096
If you want the entire ID-based chunk to be passed to the Closure at once, use ``chunkRowsById()``.
10951097

1096-
.. literalinclude:: model/070.php
1098+
.. literalinclude:: model/072.php
10971099

10981100
.. warning:: ID-based chunking needs the model to define a primary key, and that primary key must be selected.
10991101
If you customize the selected columns, make sure the primary key is included.
1100-
When joining tables, make sure the model table primary key remains available under its normal field name.
1102+
When using joins, the model primary key must remain available under its normal field name,
1103+
and each primary key value must appear only once in the result set. Otherwise, rows may be skipped.
11011104
These methods manage their own primary key ordering and cannot be used with
11021105
``orderBy()``, ``groupBy()``, ``limit()``, ``offset()`` or ``union()``.
11031106
You should also avoid changing primary key values while processing chunks.

0 commit comments

Comments
 (0)