Closed
Description
When using the feature of interface-based projection the amount of memory that is required is significant. This has been causing issues in production system in our services that have not been able to serve records with more 2 GB of heap even though the actual payload was estimated in the order of magnitude of 10 MB.
I have build a minimal working example to illustrate the issue. It's using:
org.springframework.boot:spring-boot-starter-data-jpa:3.06
openjdk Temurin-18.0.2.1+1
The example saves 100k entities in a H2 in-memory database (the same pattern can be observed when using e.g. postgres). Then it reads the ids of those entities 1) using an interface-based projection or 2) just plain Longs. While it is expected that the second representation is smaller than the first one the difference seems too big to be acceptable: