인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

열스님's profile image
열스님

asked

Real-world! Spring Boot and JPA Utilization 2 - API Development and Performance Optimization

Order Lookup V3.1: Converting Entities to DTOs - Paging and Breaking Limits

페이징 한계돌파 강의 중 문의

Written on

·

2.9K

·

Edited

0

안녕하세요?

우선 새해 복 많이 받으세요.

spring boot version: 3.0

java version: 17

order table에는 2건(강의에 나오는 주문내역과 같습니다.)의 주문 있고 offset을 적용 했을 때 조회된 데이터가 1건 이상이 조회 될 때는 order_item table조회가 in query로 데이터를 잘 가지고 오고 있습니다.

 

문제는 offset을 적용 해서 조회된 order 데이터가 1건일때

default_batch_fetch_size: 100

하나의 orderId를 위에 설정한 batch_fetch_size만큼 in query에 파라미터로 사용하고 있습니다.

OperationTime : 0ms| HeFormatSql(P6Spy sql,Hibernate format):

select

o1_0.order_id,

o1_0.order_item_id,

o1_0.count,

o1_0.item_id,

o1_0.order_price

from

order_item o1_0

where

o1_0.order_id in(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2)

혹시 이와 관련한 해결법이 있을까요?

batch_fetch_sizejavaspring-bootJPAspring

Answer 1

0

yh님의 프로필 이미지
yh
Instructor

안녕하세요. 열스님^^

이렇게 동작하는 것이 정상입니다 ㅎㅎ

하이버네이트가 내부 최적화를 위해서 이런 방법을 사용하는데요. 버전마다 최적화 방식은 조금씩 다를 수 있습니다.

자세한 내용은 다음을 참고해주세요.

https://www.inflearn.com/questions/34469

감사합니다.

열스님님의 프로필 이미지
열스님
Questioner

답변 감사합니다!

열스님's profile image
열스님

asked

Ask a question