사용자 도구

사이트 도구


java:hibernate:performance

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
java:hibernate:performance [2019/02/18 13:47]
kwon37xi
java:hibernate:performance [2020/05/24 20:42]
kwon37xi
줄 19: 줄 19:
 하지만 ''@BatchSize(size = 10)'' 처럼 해당 관계에 설정을 해 두면, Kitten 객체를 로딩할 때 Cat id 10개씩 ''**in**'' Query로 한번에 로딩한다. 하지만 ''@BatchSize(size = 10)'' 처럼 해당 관계에 설정을 해 두면, Kitten 객체를 로딩할 때 Cat id 10개씩 ''**in**'' Query로 한번에 로딩한다.
  
-  * ''hibernate.default_batch_fetch_size=100'' 프라퍼티 형태로 일괄 지정도 가능하다. +  * ''hibernate.default_batch_fetch_size=30'' 프라퍼티 형태로 일괄 지정도 가능하다. 
-  * OneToOne Eager 에 대해서는 작동하지 않았다.+  * OneToOne, ManyToOne  Eager 에 대해서는 작동하지 않았다. 
 +  * 지나치게 큰 값을 설정하지 말아야 한다. 30개 정도가 적당해 보이며, 쿼리 실행시간이 수십 밀리세컨드 이내로 끝날 수준으로 정하는게 좋다.
  
 ===== hibernate.jdbc.fetch_size ===== ===== hibernate.jdbc.fetch_size =====
줄 30: 줄 31:
 TBD TBD
  
 +===== hibernate.query.in_clause_parameter_padding=true =====
 +  * Hibernate 5.2.18 이후 버전 'hibernate.query.in_clause_parameter_padding=true'' 항상 ''true''로 둘 것.
 +  * ''IN'' 절 쿼리에 대해서 2의 제곱단위로 쿼리를 생성한다.
 +  * [[https://vladmihalcea.com/improve-statement-caching-efficiency-in-clause-parameter-padding/|How to improve statement caching efficiency with IN clause parameter padding - Vlad Mihalcea]]
 +  * 위 옵션을 켜지 않으면, ''IN'' 절 쿼리가 Query Plan Cache를 모두 점유해서 메모리가 부족해질수 있고, 메모리가 남아돌더라도 캐시를 모두 ''IN'' 절이 점유해버리므로 별로 좋지 못하다.
 +  * 또한 RDBMS 의 경우 그 자체 execution plan cache 가 있는데, 이 옵션을 켜면 그에 대한 hit 율도 높아지게 된다.
 +
 +===== Hibernate Query Plan Cache =====
 +  * [[https://vladmihalcea.com/hibernate-query-plan-cache/|A beginner’s guide to the Hibernate JPQL and Native Query Plan Cache - Vlad Mihalcea]]
 +  * ''hibernate.query.plan_cache_max_size'' 기본값은 ''2048'' 이다.
 +  * 별문제 없으면 변경하지 말 것.
 ===== autoCommit 을 꺼서 성능 향상시키기 ===== ===== autoCommit 을 꺼서 성능 향상시키기 =====
   * Connection Pool 의 ''auto commit=false''을 항상 켜고, Hibernate 에서 직접 ''auto commit=false'' 하는 것을 막아서 불필요한 ''setAutoCommit()'' 호출로 인한 성능 저하를 줄이기   * Connection Pool 의 ''auto commit=false''을 항상 켜고, Hibernate 에서 직접 ''auto commit=false'' 하는 것을 막아서 불필요한 ''setAutoCommit()'' 호출로 인한 성능 저하를 줄이기
줄 74: 줄 86:
   * [[https://vladmihalcea.com/courses/high-performance-java-persistence-mach-2/|High-Performance Java Persistence – Mach 2 - Vlad Mihalcea]]   * [[https://vladmihalcea.com/courses/high-performance-java-persistence-mach-2/|High-Performance Java Persistence – Mach 2 - Vlad Mihalcea]]
   * [[https://www.baeldung.com/hibernate-query-plan-cache|Hibernate Query Plan Cache | Baeldung]]   * [[https://www.baeldung.com/hibernate-query-plan-cache|Hibernate Query Plan Cache | Baeldung]]
 +  * [[https://dzone.com/articles/best-performance-practices-for-hibernate-5-and-spr-1|Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 3) - DZone Java]]
 +  * [[https://dzone.com/articles/50-best-performance-practices-for-hibernate-5-amp|Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 1) - DZone Java]]
 +  * [[https://dzone.com/articles/best-performance-practices-for-hibernate-5-and-spr|Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 2) - DZone Java]]
 +  * [[https://dzone.com/articles/best-performance-practices-for-hibernate-5-and-spr-1|Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 3) - DZone Java]]
 +  * [[https://dzone.com/articles/best-performance-practices-for-hibernate-5-and-spr-2|Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 4) - DZone Java]]
java/hibernate/performance.txt · 마지막으로 수정됨: 2024/03/04 12:47 저자 kwon37xi