Repository navigation
Conversation
같은 SQL이 반복돼 Generic Plan이 쓰이면 CAST(:queryVector AS vector)가 행마다 다시 실행돼 1024차원 문자열을 검색 대상 청크 수만큼 파싱했다. 스칼라 서브쿼리로 감싸 InitPlan으로 실행마다 한 번만 계산한다. - findTopK의 거리 계산·ORDER BY, findLexicalCandidates의 거리 계산 - 파라미터 타입·서비스 코드·스키마·설정은 그대로
운영 @query SQL을 그대로 PREPARE해 Generic Plan을 강제하고 검증한다. - 결과가 Custom Plan과 같은 청크·거리 순서인지 - 정렬 키가 $1을 행마다 변환하지 않고 InitPlan 결과를 쓰는지 - enable_sort=off일 때 HNSW 정렬 Index Scan을 여전히 쓰는지
- 두 results.json을 조합별 개선율·결과 일치 표와 SVG 그래프로 비교 - 수정 전/후 SQL의 Custom/Generic Plan·auto 반복 실행 psql 스크립트 - 같은 HNSW Index에서 수정 전/후 결과·실행 시간 비교 psql 스크립트
#545와 같은 환경(같은 이미지 digest·데이터·Seed·질문·하네스)에서 측정했다. - 5만 청크·topK 10 Generic Plan 벡터 검색 p50: 4,226.3 → 207.4ms (95.1%) - 수정 후 Generic Plan이 Custom Plan과 같은 속도, 검색 결과 동일 - A/B 연달아 측정, 전체 192개 조합 재측정, psql 반복 실행·같은 Index 비교
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔍️ 작업 내용
#545(PR #547) 측정에서 발견한 지연 문제를 고칩니다. 같은 벡터 검색 SQL을 6번 넘게 실행해 PostgreSQL이 Generic Plan을 쓰면,
CAST(:queryVector AS vector)가 행마다 실행돼 1024차원 문자열을 검색 대상 청크 수만큼 파싱했습니다. 질문 Vector를 스칼라 서브쿼리로 감싸 InitPlan으로 실행마다 한 번만 계산하게 했습니다.✨ 상세 설명
수정 전후 성능 (#545와 같은 환경)
5만 청크·topK 10, 질문 30개 p50입니다. 같은 SQL이 반복돼 Generic Plan이 쓰일 때의 값입니다.
auto모드 반복: 수정 전에는 6회째부터 145ms → 2,216ms로 뛰었고, 수정 후에는 18회 내내 142163ms입니다.측정 방법
PermissionRecallBenchmark)를 썼습니다. 5만 청크 HNSW Index 크기가 #545와 바이트까지 같습니다.auto모드 8회 반복, 같은 HNSW Index에서 수정 전/후 SQL 비교를 했습니다.테스트
VectorSearchRepositoryGenericPlanIntegrationTest3건(운영@QuerySQL을 그대로 PREPARE)$1을 행마다 변환하지 않는지: 수정 전 실패, 수정 후 통과enable_sort=off일 때 HNSW 정렬 Index Scan을 쓰는지: 수정 전 실패, 수정 후 통과LexicalSearchRepositoryIntegrationTest12/12 통과./backend/gradlew -p backend test(developa24d3e8+ 이번 수정, 격리 DB·Valkey): 1,511 tests, 0 failures, 0 errors, 5 skipped변경 파일
VectorSearchRepository.java: SQL 3곳 + Javadoc. 파라미터 타입·서비스 코드·스키마·설정은 그대로입니다.VectorSearchRepositoryGenericPlanIntegrationTest.java: 신규docs/test-results/evidence/issue-549/(원시 데이터 gzip, 비교 CSV·표, 그래프 4개, psql 증빙, 재현 스크립트)🛠️ 추후 리팩토링 및 고도화 계획
vector타입으로 Bind하는 방법도 검토할 수 있습니다(의존성 추가가 필요해 이번에는 하지 않음).📸 스크린샷 (선택)
수정 전후 검색 지연 (Generic Plan, 로그 축)
개선율
수정 후 결과 (#545와 같은 형식, 권한 필터 결과는 그대로)
💬 리뷰 요구사항