Skip to content

[REFACT] 월간 운동 지도 조회 공간 검색 최적화#605

Merged
Dimo-2562 merged 9 commits into
developfrom
refactor/#598
Jun 3, 2026
Merged

[REFACT] 월간 운동 지도 조회 공간 검색 최적화#605
Dimo-2562 merged 9 commits into
developfrom
refactor/#598

Conversation

@Dimo-2562
Copy link
Copy Markdown
Contributor

❤️ 기능 설명

월간 운동 지도 조회를 MySQL Spatial 기반 검색으로 최적화했습니다.

  • exercise_addr.location generated POINT 컬럼과 공간 인덱스 추가
  • 월간 지도 조회를 bbox 후보 필터 + ST_Distance_Sphere 실제 반경 필터로 변경
  • native spatial query는 ID 후보군만 조회하고, 실제 Exercise 엔티티는 JPQL fetch 조회하는 2단계 구조로 분리
  • radiusKmDouble로 유지해 소수 반경 검색 지원
  • 좌표/radius/bounding box 검증을 Query 객체로 분리
  • bounding box 계산과 MySQL WKT 변환 책임 분리
  • EXPLAIN 테스트는 운영 DB 통계값과 다른 Testcontainers 특성을 고려해 possible_keys 기반 smoke 테스트로 완화

테스트 결과 스크린샷 대신 아래 명령 실행 결과로 대체합니다.

bash ./gradlew test \
  --tests umc.cockple.demo.domain.exercise.utils.ExerciseMapBoundingBoxTest \
  --tests umc.cockple.demo.domain.exercise.repository.support.ExerciseMapSpatialSearchConditionTest \
  --tests umc.cockple.demo.domain.exercise.dto.ExerciseMapBuildingsDTOTest \
  --tests umc.cockple.demo.domain.exercise.service.ExerciseQueryServiceTest \
  --tests umc.cockple.demo.domain.exercise.repository.ExerciseRepositoryTest
# BUILD SUCCESSFUL in 28s

bash ./gradlew test --tests umc.cockple.demo.domain.exercise.integration.ExerciseRepositorySpatialIntegrationTest
# BUILD SUCCESSFUL in 2m 46s

git diff --check
# 통과

연결된 issue

close #598



🩷 Approve 하기 전 확인해주세요!

  • Flyway migration으로 exercise_addr.location generated column과 spatial index가 추가됩니다.
  • EXPLAIN 테스트는 optimizer의 실제 선택 key/type 고정이 아니라, spatial index를 사용할 수 있는 쿼리 형태인지 확인하는 smoke 테스트입니다.
  • 월간 지도 조회는 native query ID 후보군 조회 후 JPQL fetch 조회를 다시 수행하는 2단계 구조입니다.

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 테스트 결과 사진을 넣었는가? (명령 실행 결과로 대체)
  • 이슈넘버를 적었는가?

@Dimo-2562 Dimo-2562 self-assigned this May 31, 2026
@Dimo-2562 Dimo-2562 added the 🌟 REFACT New feature or request label May 31, 2026
@kanghana1 kanghana1 self-requested a review June 3, 2026 07:04
Copy link
Copy Markdown
Contributor

@kanghana1 kanghana1 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 공간인덱스 많이 배우고가요

@Dimo-2562 Dimo-2562 merged commit aa81cc0 into develop Jun 3, 2026
1 check passed
@Dimo-2562 Dimo-2562 deleted the refactor/#598 branch June 3, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟 REFACT New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACT] 월간 운동 지도 조회 공간 검색 최적화

2 participants