Question 1
A query is known to return 500,000 rows. Which two are recommended to process all 500,000 rows efficiently? (Select two)
Processing extremely large datasets---such as a result set containing 500,000 rows---presents a significant risk to application stability and performance. If a developer attempts to load all these records into the application server's memory simultaneously, it will likely trigger an OutOfMemoryError, as each entity instance consumes heap space. To mitigate this, Guidewire's Query API provides mechanisms for "lazy loading" and memory management.
The primary recommendation for handling massive result sets is to use setPageSize() (Option B). When setPageSize is configured on a query object, the system does not fetch all 500,000 rows at once. Instead, it retrieves data in smaller, manageable "chunks" or pages from the database. For example, if the page size is set to 100, the application only holds 100 entity instances in memory at any given time while iterating. As the iterator moves to the 101st record, the next page is transparently fetched. This process of chunking results into page sets (Option E) ensures that the memory footprint remains constant regardless of the total size of the result set.
While a batch process (Option C) is often used for long-running tasks, the question specifically asks how to process the query efficiently. Simply moving the code to a batch process without using setPageSize() would still result in a memory failure within that batch thread. Therefore, pagination is the underlying technical requirement for efficiency. Sorting (Option D) and external libraries like Google Iterables (Option A) do not address the fundamental memory consumption issues associated with large-scale database retrieval in the Guidewire platform.

