[Feature] - default_batch_fetch_size 적용 #647
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✅ 작업 내용
🙈 참고 사항
현재 JPA 연관관계로 인해 데이터를 가져올 때 SELECT한 row 수 만큼 추가 쿼리가 발생하는 N+1문제가 발생합니다.
연관된 객체를 가져올 때 batch_size만큼 가져오도록 설정하여 N+1문제를 완화할 수 있습니다.
default_batch_fetch_size를 적용하여 한번에 100개씩 IN절을 활용하여 가져오도록 최적화 되었습니다.
성능 측정
26.83프로 성능 개선 달성
Jmeter 테스트 시나리오
batch_fetch_size 미지정
batch_fetch_size 100 설정
발생 쿼리 비교
발생 쿼리 비교
batch_fetch_size 미지정
batch_fetch_size 지정