I'm trying to send in large IN clause (possibly in thousands) in a Criteria Query using JPA and the query has reached its limit and ran out resources in SQLServer (error 8623).
The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
I'm aware that this is not a good practice to send in large set in IN clause.
As the results are paginated, partitioning and aggregating the results are not possible.
TypedQuery<T> typedQuery = entityManager.createQuery(criteriaQuery)
.setLockMode(LockModeType.NONE)
.setHint(QueryHints.READ_ONLY, true)
.setFirstResult(0)
.setMaxResults(10);
I'm looking for possible solutions and suggestions to overcome this limit.