reconcile(accounts, payments) returns {id, balance} rows in account order. Each balance is the sum of matching payment amounts; accounts without payments get zero, and payments for unknown accounts are ignored. Duplicate account IDs must each get the same balance.
Two reports from the nightly job:
- With array inputs the balances are right, but the job gets slower much faster than the data grows: doubling both the accounts and the payments makes it roughly four times slower, and the largest tenants no longer finish in the job window.
- Since payments started arriving as a streamed iterable (read once from a cursor), only the first account gets its payments; every later account shows a balance of
0.