perf(banking): stream dedup key preload with a cursor
get() buffered every historical transaction row for the account into a Collection on top of the two dedup sets, so a pathological account with 100k+ rows could spike the queue worker's memory. cursor() streams the rows instead, capping peak memory at the sets themselves.
This commit is contained in:
parent
6726b2e833
commit
d74d09ad33
|
|
@ -156,10 +156,13 @@ class TransactionSyncService
|
|||
$knownFingerprints = [];
|
||||
$knownExternalIds = [];
|
||||
|
||||
// cursor() streams rows so peak memory is the two sets, not an extra
|
||||
// buffered Collection of every historical row on top of them.
|
||||
$rows = $account->transactions()
|
||||
->withTrashed()
|
||||
->toBase()
|
||||
->get(['dedup_fingerprint', 'external_transaction_id']);
|
||||
->select(['dedup_fingerprint', 'external_transaction_id'])
|
||||
->cursor();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if ($row->dedup_fingerprint !== null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue