-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Currently, a lot of pagination happens in-memory, which is very slow. This is shown by the error message
WARN 1 --- [ XNIO-1 task-6] o.h.h.internal.ast.QueryTranslatorImpl : HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!
This happens for any HQL query that has a join or left join fetch statement.
According to https://vladmihalcea.com/fix-hibernate-hhh000104-entity-fetch-pagination-warning-message/, to avoid this message a two-query approach is preferred:
- query all ID's that match the criteria with a pageable
- query the entities that match given ids
it.id IN (:ids), returning aList - convert the result list into a page
This takes advantage of the SQL paging. A downside is that now two queries are necessary, and that some complexity is added.
Metadata
Metadata
Assignees
Labels
No labels