Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
@Entity
@Getter
@Table(indexes = {
@Index(name = "idx_coursePath", columnList = "course_path"),
@Index(name = "idx_problemId", columnList = "problem_id"),
@Index(name = "idx_answerType", columnList = "answer_type"),
@Index(name = "idx_location", columnList = "location"),
@Index(name = "idx_difficulty", columnList = "difficulty"),
@Index(name = "idx_totalAttemptedCount", columnList = "total_attempted_count"),
@Index(name = "idx_firstTrySuccessCount", columnList = "first_try_success_count desc"),
@Index(name = "idx_attemptedUserDistinctCount", columnList = "attempted_user_distinct_count desc"),
@Index(name = "idx_accuracy", columnList = "accuracy desc"),
@Index(name = "idx_pastProblem", columnList = "past_problem"),
@Index(name = "idx_singleProblem_coursePath", columnList = "course_path"),
@Index(name = "idx_singleProblem_problemId", columnList = "problem_id"),
@Index(name = "idx_singleProblem_answerType", columnList = "answer_type"),
@Index(name = "idx_singleProblem_location", columnList = "location"),
@Index(name = "idx_singleProblem_difficulty", columnList = "difficulty"),
@Index(name = "idx_singleProblem_totalAttemptedCount", columnList = "total_attempted_count"),
@Index(name = "idx_singleProblem_firstTrySuccessCount", columnList = "first_try_success_count desc"),
@Index(name = "idx_singleProblem_attemptedUserDistinctCount", columnList = "attempted_user_distinct_count desc"),
@Index(name = "idx_singleProblem_accuracy", columnList = "accuracy desc"),
@Index(name = "idx_singleProblem_pastProblem", columnList = "past_problem"),
})
Comment on lines 36 to 47
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

인덱스 이름에 접두사를 붙여 이름 충돌을 해결하신 것은 좋은 수정입니다. 이 기회에 인덱싱 전략을 검토하여 성능을 개선하는 것을 제안합니다.

현재는 여러 컬럼에 대해 개별 인덱스를 생성하고 있습니다. 하지만 SingleProblemQueryServicequeryPage를 보면 여러 조건을 조합하여 검색하는 경우가 많을 것으로 예상됩니다. 이 경우 단일 컬럼 인덱스보다 복합 인덱스가 훨씬 효율적일 수 있습니다.

예를 들어, coursePath로 필터링한 후 difficultyaccuracy로 추가 필터링하거나 정렬하는 일반적인 사용 사례를 위해 다음과 같은 복합 인덱스를 추가하는 것을 고려해볼 수 있습니다.

@Table(indexes = {
    // ... 기존 인덱스 일부 ...
    @Index(name = "idx_singleProblem_coursePath_difficulty", columnList = "course_path, difficulty"),
    @Index(name = "idx_singleProblem_coursePath_accuracy", columnList = "course_path, accuracy desc"),
    // ... 나머지 인덱스 ...
})

새로운 복합 인덱스를 추가하면 course_path만으로 검색하는 쿼리에도 해당 인덱스가 사용될 수 있으므로, 기존의 idx_singleProblem_coursePath 같은 단일 인덱스는 중복으로 간주되어 제거할 수 있습니다. 이를 통해 인덱스 관리 비용을 줄일 수 있습니다.

가장 자주 사용되는 쿼리 패턴을 분석하여 최적의 복합 인덱스를 설계하는 것이 장기적인 성능에 도움이 될 것입니다.

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Setter
Expand Down
Loading