Skip to content

Commit 912a8b9

Browse files
authoredNov 1, 2018
Update README.md
1 parent 32f77dd commit 912a8b9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎README.md

+4
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ of sorting by name for Human objects. The default sort order can be specified us
320320

321321
Performance
322322
-----------
323+
Lazy loading of associations between entities is a well established best practice in JPA. Its main goal is to retrieve only the requested entities from the database and load the related entities only if needed. The use of FetchType.EAGER for associations mapping is one of the most common reasons for performance problems, because Hibernate loads eagerly fetched associations when it loads an entity. This is very inefficient and it gets even worse when you consider that Hibernate does that whether or not you will use the associated data.
324+
323325
The JPA DataFetcher implementation will attempt to build dynamic fetch graph in order to optimize query performance and avoid N+1 lazy loading. However, if there are composite foreign keys being used on `@ManyToOne` association declared in GraphQL query, Hibernate persistence provider will issue a separate SQL query to resolve the parent entity.
324326

327+
To disable default `@ManyToOne` associations default behavior of eager fetch, make explicit use of FetchType.LAZY for all to-many associations in your entity model. It will delay the initialization of the relationship unless it is specified in the GraphQL query entity graph to improve performance when fetching many entities with to-one associations.
328+
325329
GraphiQL Browser
326330
--------
327331

0 commit comments

Comments
 (0)