Skip to content

[Refactor] 산 이름/주소 검색에 pg_trgm GIN 인덱스 적용 - #395

Merged
pooreumjung merged 1 commit into
developfrom
refactor/#330-mountain-search-trigram-index
Aug 30, 2026
Merged

pooreumjung merged 1 commit into
developfrom
refactor/#330-mountain-search-trigram-index

Conversation

@pooreumjung

Copy link
Copy Markdown
Member

🧾 요약

  • 산 이름/주소 검색(LIKE '%keyword%')이 인덱스 없이 풀스캔하던 문제 개선 — 자유게시판(V13)과 동일한 pg_trgm GIN 인덱스 패턴 적용

🔗 이슈

✨ 변경 내용

  • V42__add_mountain_search_index.sql 추가 — mountains.name/address에 pg_trgm GIN 인덱스 생성
  • Java 코드 변경 없음 — 기존 searchByKeyword/searchByKeywordAll/searchByKeywordAndVisibility 3곳 모두 이미 LIKE '%keyword%'라 인덱스만 생기면 planner가 알아서 사용

📊 측정 결과 (로컬 Postgres, 더미 산 10만 건 + 매칭 15건 시딩 후 트랜잭션 롤백)

검색어 길이 Seq Scan GIN Index
2글자 (관악) 15.9 ms 87.2 ms (index가 오히려 느림)
3글자 이상 (관악산) 61.7 ms 1.5 ms (약 40배)

pg_trgm의 최소 trigram 단위가 3글자라 2글자 검색어는 인덱스 선택성이 낮아 오히려 느려질 수 있음 — 다만 planner가 자동으로 유리한 쪽(이 경우 Seq Scan)을 선택하므로 애플리케이션 동작에는 문제없음.

✅ 확인

  • 빌드 OK
  • 테스트 OK

@pooreumjung pooreumjung self-assigned this Aug 30, 2026
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • src/main/resources/db/migration/V42__add_mountain_search_index.sql is excluded by !src/main/resources/db/migration/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c390aa9-2d91-4b7b-bb5c-bc354171fc23

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

📊 테스트 커버리지 리포트

Overall Project 98.35% 🍏

There is no coverage information present for the Files changed

@pooreumjung
pooreumjung merged commit 80e1534 into develop Aug 30, 2026
5 checks passed
@pooreumjung
pooreumjung deleted the refactor/#330-mountain-search-trigram-index branch August 30, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] 산 이름/주소 검색에 trigram GIN 인덱스 적용

1 participant