Uh oh!
There was an error while loading. Please reload this page.
perf: PublicCourseService.deletePublicCourses N+1 제거 - #247
Conversation
findByIdIn으로 조회한 PublicCourse의 course(OneToOne LAZY)/ runnectUser(ManyToOne LAZY)/records(OneToMany LAZY)를 각각 순회하며 지연로딩을 트리거해 최대 3N+1 쿼리가 나가고 있었음. JOIN FETCH로 한 번에 즉시로딩하는 findByIdInWithCourseAndRecords로 교체. 기존 findById()에 이미 쓰이던 JOIN FETCH 패턴을 그대로 확장한 것.
Warning Review limit reached
Next review available in:10 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
작업 배경
PublicCourseRepository.findByIdIn())를 실제로 검증하지 않고 남겨뒀던 항목PublicCourseService.deletePublicCourses에서findByIdIn으로 조회한PublicCourse목록을 순회하며getCourse()(OneToOne LAZY),getCourse().getRunnectUser()(ManyToOne LAZY),getRecords()(OneToMany LAZY)를 각각 호출 — 삭제 대상이 N개면 최대 3N+1 쿼리가 나가는 구조였음변경 사항
PublicCourseRepository.javafindByIdInWithCourseAndRecords추가 —course/course.runnectUser/records를 JOIN FETCH로 한 번에 즉시로딩PublicCourseService.javadeletePublicCourses에서findByIdIn→findByIdInWithCourseAndRecords교체PublicCourseServiceTest.java선택지 및 근거
findById()가 이미 프로덕션에서 쓰고 있는JOIN FETCH pc.course패턴을 그대로 확장한 것 —JOIN FETCH c.runnectUser,LEFT JOIN FETCH pc.records추가는 이미 검증된 패턴의 자연스러운 연장영향 범위
deletePublicCourses(공개 코스 삭제 API) 쿼리 수만 변경, 응답/동작은 동일검증 관련 특이사항
@DataJpaTest로 실제 DB에 대해 JOIN FETCH 즉시로딩 여부를 검증하려 했으나, 로컬 Docker Postgres 컨테이너의 PostGIS 공유 라이브러리 결함($libdir/postgis-3없음 — 이 세션에서 이미 겪은 것과 동일한 로컬 전용 이슈)과 PgJDBC 드라이버의 타입 조회 방식이 얽혀course테이블에 새 row를 INSERT하는 것 자체가 로컬에서 막힘. raw psql/PREPARE·EXECUTE로는 동일 SQL이 정상 동작해, 코드 로직이 아니라 로컬 환경 결함으로 판단해 해당 통합 테스트는 제외함.ServerApplicationTests.contextLoads()가 새@QueryJPQL을 엔티티 메타모델 기준으로 파싱/검증하며 통과 (2) 서비스 계층 mock 테스트 4건 갱신 후 통과Test Plan
./gradlew test)🤖 Generated with Claude Code