Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] JPA의 saveAll, deleteAll를 bulk query로 개선해요 :) #256

Closed
2 tasks done
seokmyungham opened this issue Aug 18, 2024 · 0 comments · Fixed by #273
Closed
2 tasks done

[BE] JPA의 saveAll, deleteAll를 bulk query로 개선해요 :) #256

seokmyungham opened this issue Aug 18, 2024 · 0 comments · Fixed by #273
Assignees
Labels
♻️ 리팩터링 코드를 깎아요 :) 🐈‍⬛ 백엔드 백엔드 관련 이슈에요 :)

Comments

@seokmyungham
Copy link
Contributor

seokmyungham commented Aug 18, 2024

이슈 요약

현재 일정 생성 시 JPA의 saveAll(), deleteAll() 메서드를 호출하고 있습니다.
saveAll()deleteAll() 메서드는 JPA에서 다수의 엔티티를 일괄적으로 처리할 수 있도록 제공하는 기능인데요.
추가로 hibernate.jdbc.batch_size 옵션을 사용하면 여러 쿼리를 하나의 배치로 묶어 한 번에 처리할 수 있습니다.

하지만 id 생성 전략이 AutoIncrement(Identity) 일 경우
Batch Processing이 Hibernate의 쓰기 지연 철학과 충돌하여 엔티티 수 만큼 개별적인 insert, delete 쿼리가 발생합니다.

Hibernate disables insert batching at the JDBC level transparently if you use an identity identifier generator.

이를 jdbc의 batch update를 직접 구현하여 일괄처리 할 수 있도록 개선합니다.

상세 작업 내용

  • jdbc batch update를 직접 구현하여 insertAll() 개선
  • jdbc batch update를 직접 구현하여 deleteAll() 개선

레퍼런스

@seokmyungham seokmyungham added 🐈‍⬛ 백엔드 백엔드 관련 이슈에요 :) ♻️ 리팩터링 코드를 깎아요 :) labels Aug 18, 2024
@seokmyungham seokmyungham added this to the 4차 데모데이 milestone Aug 18, 2024
@seokmyungham seokmyungham self-assigned this Aug 18, 2024
@seokmyungham seokmyungham changed the title [BE] JPA의 saveAll, deleteAll를 jdbc bulk query로 개선해요 :) [BE] JPA의 saveAll, deleteAll를 bulk query로 개선해요 :) Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️ 리팩터링 코드를 깎아요 :) 🐈‍⬛ 백엔드 백엔드 관련 이슈에요 :)
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant