Topic: Advanced Gosu
A policy renewal batch validates 200,000 submissions. A validation rule calls a helper that performs a database query for each submission, and runtime rises sharply as the batch grows. The rule must continue to report the same validation failures, while the team wants to avoid unnecessary database round trips and cannot weaken the validation criteria. What is the best change?
Bulk retrieval avoids the per-submission query pattern while preserving the rule's validation logic. A Gosu enhancement changes where code is organized, not how often its query executes. Asynchronous execution changes timing and can allow invalid submissions to commit before validation. A count query per submission still performs repeated database work and may not retrieve the data needed to evaluate each failure.