I uploaded hibernate6-eager-fetching-performance-issue.zip with two sample projects, one using Spring Boot 3 and Hibernate 6 and the other using Spring Boot 2 and Hibernate 5. Even the domain classes can be optimized - I detected two unnecessary eager fetchings - we can see that Hibernate 6 is significantly slower than Hibernate 5 when fetching the collections. The log files included in the ZIP file show two runs with 200 C1Sets. First the run of H6Sample creates the C1Sets and then lists them. Second the run of H5Sample uses the same data to list all C1Sets. Time needed for listing: 40 seconds vs 1.5 seconds using Postgres 13 H6Sample: http://localhost:8086/c1sets http://localhost:8086/swagger-ui/index.html#/c-1-set-controller/listAll H5Sample http://localhost:8085/c1sets http://localhost:8085/swagger-ui/index.html#/c-1-set-controller/listAll In BootstrapService the number of C1Sets to be created can be changed. Maybe you want more C1Sets e.g. when using using an H2 database for the tests - or less. Using Postgres 20 C1Sets are enough to see a difference. I hope this helps finding a solution for this issue. |