Queries should use a reasonable value of “results per fetch” when a large total result set size is expected. The maximum result size should not exceed the memory allocated for the query engine on the server side. If it does, then the query will fail. Dropping the query result size will allow the query to succeed.
If you incorrectly estimate how much memory will be used by the result set, the server will not fail gracefully with an appropriate error message, but will instead run out of memory.
Suggested values are in the 2000-5000 range. Set maxFetchSize = 4098 as an argument to the query method.