Add n-plus-one-guard module: detecting N+1 with Hibernate Statistics vs datasource-proxy, five fixes with statement counts, and a JUnit 6 @MaxSelects guard (Hibernate 7.4.16.Final, datasource-proxy 1.11.1)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6R1spapM7nBteaqeo
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
eab5461d86
commit
0db721805b
@@ -0,0 +1,23 @@
|
||||
# N+1 on a lazy collection: 10 authors, 3 books each
|
||||
# Hibernate ORM 7.4.16.Final, datasource-proxy 1.11.1, H2, JDK 25
|
||||
|
||||
== Code: one HQL query, then a.getBooks().size() for every author
|
||||
books counted by the loop : 30
|
||||
datasource-proxy SELECT count : 11
|
||||
Hibernate prepareStatementCount : 11
|
||||
Hibernate queryExecutionCount : 1
|
||||
Hibernate collectionFetchCount : 10
|
||||
Hibernate collectionLoadCount : 10
|
||||
|
||||
== The statements, in order
|
||||
sql> select a1_0.id,a1_0.name from Author a1_0
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
sql> select b1_0.author_id,b1_0.id,b1_0.title from Book b1_0 where b1_0.author_id=?
|
||||
Reference in New Issue
Block a user