fix: practice_result 테이블에 (type, started_at) 복합 인덱스 추가로 랭킹 조회 커넥션 고갈 방지#43
Draft
Jeongho0805 wants to merge 1 commit into
Draft
fix: practice_result 테이블에 (type, started_at) 복합 인덱스 추가로 랭킹 조회 커넥션 고갈 방지#43Jeongho0805 wants to merge 1 commit into
Jeongho0805 wants to merge 1 commit into
Conversation
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.
변경 사항
PracticeResult엔티티에@Table(indexes = {...})선언 추가(type, started_at)복합 인덱스(idx_practice_result_type_started_at) 정의배경
Sentry 이슈 PRACTICKET-5D:
GET /api/practice/rank요청에서 HikariPool-1 커넥션 고갈 발생 (total=10, active=10, idle=0, waiting=190).PracticeRankRepositoryImpl.findRanking()이 실행하는 윈도우 함수 쿼리는WHERE type = :type AND started_at >= :startDateTime조건으로practice_result테이블을 조회한다. 해당 컬럼에 인덱스가 없어 매 요청마다 전체 테이블 스캔이 발생하고, 쿼리가 오래 걸리는 동안 DB 커넥션이 점유된다. 동시 요청이 증가하면 기본 풀 크기(10)가 모두 소진되어 이후 요청이 30초 타임아웃 후 실패한다.