Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the nearby store search to utilize PostGIS GIST indexing instead of manual bounding box calculations, removes a duplicate B-tree index from the migration script, limits the query size in getStoresInBounds, and adds a Grafana panel for Kafka message throughput. The review feedback highlights a critical issue where the location field's non-insertable/non-updatable configuration in the Store entity could lead to NULL values and missing search results for new stores. Additionally, it suggests safeguarding PageRequest creation against values less than 1 for both size and limit parameters to prevent runtime exceptions.
| latitude, longitude, | ||
| latitude - deltaLat, latitude + deltaLat, | ||
| longitude - deltaLng, longitude + deltaLng, | ||
| return storeRepository.findNearbyWithGist( |
There was a problem hiding this comment.
현재 Store 엔티티(Store.java 50-51라인)를 보면 location 필드가 @Column(columnDefinition = "geography(Point, 4326)", insertable = false, updatable = false)로 설정되어 있어, 애플리케이션 단에서 신규 매장을 등록할 때 location 값이 저장되지 않고 NULL로 입력됩니다.\n\n만약 PostgreSQL DB 상에 latitude와 longitude 변경 시 location을 자동으로 업데이트해주는 DB Trigger가 별도로 존재하지 않는다면, 신규 등록된 매장은 location이 NULL이 되어 findNearbyWithGist 검색 결과에서 누락되는 문제가 발생할 수 있습니다.\n\n해결 방안:\n1. DB 마이그레이션 스크립트에 latitude/longitude 삽입/수정 시 location을 자동 갱신하는 Trigger를 추가합니다.\n2. 또는 Store 엔티티의 location 필드를 insertable = true, updatable = true로 변경하고, 매장 생성/수정 비즈니스 로직에서 GeometryFactory를 이용해 Point 객체를 직접 생성하여 저장하도록 수정합니다.
| // 내 주변 매장 (PostGIS GIST 인덱스 + ST_DWithin + KNN 거리 정렬) | ||
| @Transactional(readOnly = true) | ||
| public List<StoreListResponse> getNearbyStores(double latitude, double longitude, int page, int size) { | ||
| int limitedSize = Math.min(size, 100); |
| public List<StoreListResponse> getStoresInBounds( | ||
| double minLat, double maxLat, double minLng, double maxLng, | ||
| Double centerLat, Double centerLng, int limit) { | ||
| int limitedLimit = Math.min(limit, 100); |
📢 기능 설명
필요시 실행결과 스크린샷 첨부
연결된 issue
연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.
close #{이슈넘버}
✅ 체크리스트