문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 마지막 판 양쪽 다음 판 | ||
java:hibernate:performance [2021/09/07 17:21] kwon37xi [hibernate.jdbc.batch_size] |
java:hibernate:performance [2024/01/10 16:18] kwon37xi [autoCommit 을 꺼서 성능 향상시키기] |
||
---|---|---|---|
줄 9: | 줄 9: | ||
===== Hibernate 성능 분석 ===== | ===== Hibernate 성능 분석 ===== | ||
* [[java: | * [[java: | ||
+ | * [[java: | ||
- | ==== Join Fetch ==== | + | ===== N+1 ===== |
- | * JPQL 에서 '' | + | * [[https:// |
+ | * https:// | ||
+ | * [[https:// | ||
+ | ===== Join Fetch ===== | ||
+ | * JPQL 에서 '' | ||
+ | * 하지만 **1:N 관계에서 1측이 N 만큼 반복 조회되는 문제가 있다. 실제 엔티티 객체가 여러개 생성된다.** | ||
+ | * **limit 을 걸더라도 limit 이 DB에 걸리지 않고 모두 조회후 메모리에 걸리게 된다.** | ||
+ | * 따라서 '' | ||
+ | * see [[java: | ||
+ | * [[java: | ||
===== @org.hibernate.annotations.BatchSize ===== | ===== @org.hibernate.annotations.BatchSize ===== | ||
'' | '' | ||
줄 36: | 줄 46: | ||
* '' | * '' | ||
* [[https:// | * [[https:// | ||
- | * 위 옵션을 켜지 않으면, '' | + | * 위 옵션을 켜지 않으면, '' |
* 또한 RDBMS 의 경우 그 자체 execution plan cache 가 있는데, 이 옵션을 켜면 그에 대한 hit 율도 높아지게 된다. | * 또한 RDBMS 의 경우 그 자체 execution plan cache 가 있는데, 이 옵션을 켜면 그에 대한 hit 율도 높아지게 된다. | ||
+ | <note warning> | ||
+ | [[database: | ||
+ | 특히 200 개 기준인게 보통인데, | ||
+ | |||
+ | in 에 들어가는 값이 128 을 초과하지 않게 파티셔닝하고 관리하는게 좋다. '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | 참조 : [[https:// | ||
+ | </ | ||
===== Hibernate Query Plan Cache ===== | ===== Hibernate Query Plan Cache ===== | ||
* [[https:// | * [[https:// | ||
줄 45: | 줄 66: | ||
===== autoCommit 을 꺼서 성능 향상시키기 ===== | ===== autoCommit 을 꺼서 성능 향상시키기 ===== | ||
* Connection Pool 의 '' | * Connection Pool 의 '' | ||
+ | |||
+ | <note warning> | ||
+ | 아주 많은 Spring의 확장들이 auto commit=true를 가정하고 만들어져 있는 것으로 보인다. | ||
+ | |||
+ | auto commit=false 이면서 Spring Data 사용시 제대로 Transaction이 안 걸려 있으면 오동작이 발생한다. | ||
+ | 모든 Repository 인터페이스와 Custom 구현에 '' | ||
+ | </ | ||
+ | |||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
줄 51: | 줄 80: | ||
* [[springframework: | * [[springframework: | ||
* [[https:// | * [[https:// | ||
+ | * https:// | ||
* '' | * '' | ||
if (!vendorProperties.containsKey(PROVIDER_DISABLES_AUTOCOMMIT)) { | if (!vendorProperties.containsKey(PROVIDER_DISABLES_AUTOCOMMIT)) { | ||
줄 92: | 줄 122: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// |