강의

멘토링

커뮤니티

Inflearn Community Q&A

terecal0050's profile image
terecal0050

asked

Real-world! Spring Boot and JPA Utilization 1 - Web Application Development

Considerations for Entity Design

n+1 문제 개념이 이게 맞나요?

Written on

·

315

1

오더 엔티티에서 패치 타입이  아래와 같다면

    @ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "member_id")
private Member member;

오더가 100일 경우 각각의 오더에 대한 멤버 정보를 조회하기 위해 쿼리를 1번씩 더 날리게 됨 

그래서 오더가 100개인것에 대해 1번씩 더한다고 해서 

n+1 문제가 되는건가요? 그럼 성능상 문제가 될수 있고 

    @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;

이렇게 바꾸면  오더 엔티티를 조회할때 오더 테이블만 조회하는게 되서 성능상으로 무리가 안간다는 거죠?

JPAspringjavaspring-boot웹앱

Answer 1

2

yh님의 프로필 이미지
yh
Instructor

안녕하세요. terecal님

다음을 참고해주세요.

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

감사합니다.

terecal0050's profile image
terecal0050

asked

Ask a question