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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인덱스 컬럼 순서 선택 (status 선행, deadline 후행)은 두 쿼리의 사용 패턴에 잘 맞습니다.
다만 두 쿼리에서 이 인덱스가 활용되는 방식이 다릅니다:
findAllRetryableCycles— 인덱스를 완전히 활용(status, deadline)복합 인덱스가 두 컬럼 모두 활용되어range스캔으로 개선됩니다.findAllByScheduledAt—statusprefix만 활용이 쿼리에는
deadline이 WHERE 조건에 없으므로statusprefix만 사용됩니다 (EXPLAIN의ref결과가 이를 반영). 해당 쿼리 단독이라면(status)단일 인덱스와 동일한 효과이지만,findAllRetryableCycles를 위해deadline을 추가한 설계이므로 두 쿼리를 하나의 인덱스로 커버하는 합리적인 선택입니다.추가로
findAllByScheduledAt의rc.scheduledAt <= :scheduledAt조건은review_cycle테이블을 필터링하는데,review_cycle.scheduled_at에 인덱스가 없다면 이 부분에서도 풀스캔이 발생할 수 있습니다. 데이터 규모가 커질 경우review_cycle(scheduled_at)인덱스도 함께 검토해보면 좋을 것 같습니다.