백엔드

    [Spring] JPA N + 1 문제 발생 원인 및 해결 방안

    [Spring] JPA N + 1 문제 발생 원인 및 해결 방안

    📌 JPA N + 1 문제란?조회된 데이터 개수만큼, 연관 관계의 조회 쿼리가 추가로 발생하는 문제를 의미한다. EX) 카테고리와 게시글@Entity @NoArgsConstructor @Setter @Getter public class Board { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String title; private String content; @ManyToOne private Category category; public Board(String title, String content, Category category) { this.title = title; this.content = co..