How To Quickly Reproduce The N+1 Performance Issue
Description: The N+1 is an issue of lazy fetching (but, eager is not exempt). This application reproduce the N+1 behavior.
Key points:
- define two entities,
AuthorandBookin a lazy bidirectional@OneToManyassociation - fetch all
Booklazy, so withoutAuthor(results in 1 query) - loop the fetched
Bookcollection and for each entry fetch the correspondingAuthor(results N queries) - or, fetch all
Authorlazy, so withoutBook(results in 1 query) - loop the fetched
Authorcollection and for each entry fetch the correspondingBook(results N queries)


