사용자 도구

사이트 도구


java:hibernate:performance

문서의 이전 판입니다!


Hibernate Performance Tuning

Hibernate 성능 분석

Join Fetch

  • JPQL 에서 join fetch를 통해서 (inner join등 명시) N + 1 대신에 미리 join 문으로 객체를 로딩할 수 있다.

@org.hibernate.annotations.BatchSize

batch-size 설정은 OneToMany 등의 관계에서 Many쪽 Lazy Proxy 객체를 로딩할때, 한번에 로딩할 갯수를 지정한다. 예를들면 Cat 객체가 Kitten 객체의 리스트를 Lazy로 가지고 있을 때 List<Cat> 을 돌면서 getKittens()를 실행하면 각각의 Cat에 대해 한번씩 쿼리가 날라간다.(n + 1 problem)

하지만 @BatchSize(size = 10) 처럼 해당 관계에 설정을 해 두면, Kitten 객체를 로딩할 때 Cat id 10개씩 in Query로 한번에 로딩한다.

  • hibernate.default_batch_fetch_size=100 프라퍼티 형태로 일괄 지정도 가능하다.
  • OneToOne Eager 에 대해서는 작동하지 않았다.

hibernate.jdbc.fetch_size

hibernate.jdbc.batch_size

TBD

autoCommit 을 꺼서 성능 향상시키기

in Hibernate 5.2.10, we introduced the hibernate.connection.provider_disables_autocommit configuration property which tells Hibernate that the underlying JDBC Connections already disabled the auto-commit mode.

Assert statement count

Index Hint

Stateless Session

  • 1st/2nd level cache 등이 없고 상태가 없는 Session 모드.

참조 문서

java/hibernate/performance.1550465229.txt.gz · 마지막으로 수정됨: 2019/02/18 13:47 저자 kwon37xi