we're running a central instance of a simulator, which contains around 30'000 scenario executions right now. whenever we access the "Scenario Execution" UI (/scenario-result), the simulator instantly runs out of memory.
Expected Behavior
The UI displays the paginated Scenario Execution information (without problems).
More Detailed Explanation
We're in the ScenarioExecutionQueryService, about to fire the query. The simulator logs a warning in the moment the query will be executed:
[TIMESTAMP]: HHH90003004: firstResult/maxResults specified with collection fetch; applying in memory
The problem is, that because of JOIN FETCH clauses, the SQL query does not include the paging information. That is not possible, due to the nature of the result. See this good blog by Thorben Janssen about the problem.
What should be done instead, is selecting the ID's of the entities using a first query with pagination, then selecting the full entity with relationship in a second query - limited to the previously selected ID's.
Bug
we're running a central instance of a simulator, which contains around 30'000 scenario executions right now. whenever we access the "Scenario Execution" UI (/scenario-result), the simulator instantly runs out of memory.
Expected Behavior
The UI displays the paginated Scenario Execution information (without problems).
More Detailed Explanation
We're in the
ScenarioExecutionQueryService
, about to fire the query. The simulator logs a warning in the moment the query will be executed:The problem is, that because of
JOIN FETCH
clauses, the SQL query does not include the paging information. That is not possible, due to the nature of the result. See this good blog by Thorben Janssen about the problem.What should be done instead, is selecting the ID's of the entities using a first query with pagination, then selecting the full entity with relationship in a second query - limited to the previously selected ID's.