Skip to content

Conversation

@junyoungkim12
Copy link
Contributor

발표 자료

영속성 컨텍스트

📌 Focus On

📚 공유하고 싶은 내용

@junyoungkim12 junyoungkim12 requested a review from a user April 22, 2024 15:36
@junyoungkim12 junyoungkim12 self-assigned this Apr 22, 2024
@junyoungkim12 junyoungkim12 added the needs review 리뷰가 필요한 경우 label Apr 22, 2024
Copy link
Contributor

@hanni66 hanni66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 궁금했던 지점들을 잘 설명해주신 것 같아요~!
수고 많으셨습니다~!😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 영속성 컨텍스트의 지연 로딩 기능은 어떤 역할을 하나요?

Copy link
Contributor Author

@junyoungkim12 junyoungkim12 Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JPA에서는 데이터를 조회할 때 즉시 로딩(EAGER)과 지연 로딩(LAZY) 두 가지 방식이 있는데,
즉시 로딩은 데이터를 조회할 때 연관된 데이터까지 한 번에 불러오는 것이고,
지연 로딩은 필요한 시점에 연관된 데이터를 불러오는 것 입니다.

만약 Member 엔티티와 Team 엔티티가 N:1 매핑으로 관계를 맺고 있을 때
즉시 로딩으로 Member를 조회하면 연관된 Team의 수 만큼 Join되어 쿼리가 나가게 됩니다.

그 결과 조회 쿼리 하나가 아닌 많은 쿼리문을 수행하게 되어 성능이 저하됩니다.

그러나 지연 로딩을 사용하면 Member만 조회할 수 있어서 많은 쿼리문을 실행하지 않을 수 있기 때문에
필요한 객체의 데이터만 불러올 수 있는 장점이 있다고 합니다!

출처

Copy link
Contributor

@ByeongJun-Jang ByeongJun-Jang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니담

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review 리뷰가 필요한 경우

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants