Workflow mutation timing out with high participant volume
I have a mutation that's timing out when processing tournament rewards. This mutation is being called from a Convex Workflow using step.runMutation() as part of a multi-phase tournament completion process.
The problem:
My mutation needs to:
1. Paginate through all participants in a tournament (potentially 500-1000+ participants)
2. For each participant, process their selections (up to 6 items)
3. For each selection, perform 2-3 database operations (decrement counter, check prizes, insert reward)
4. Call 2 additional mutations via ctx.runMutation() to update totals
5. Current implementation: Single mutation with nested loops performing ~15-20 DB operations per participant
Scale: With 500 participants, this results in ~7,500-10,000 database operations in one mutation, causing timeouts.
What's the recommended pattern for processing large batches with nested operations in a workflow context?
0 Replies