Skip to content

Conversation

@Ji-soo708
Copy link
Member

@Ji-soo708 Ji-soo708 commented May 21, 2025

💡 작업 내용

  • recruit_status, end_date 복합 인덱스 생성

    • 스크린샷 2025-05-22 오전 12 45 02
    • recruit_statustrue인 게시글 중에서 end_date 기준으로 필터링하는 쿼리의 성능을 개선하기 위해 추가
  • recruit_status, created_at 복합 인덱스 생성

    • 스크린샷 2025-05-22 오전 12 47 37
    • recruit_statustrue인 게시글을 created_at 기준으로 정렬하는 쿼리에서 성능 향상을 노리기 위해 추가

실행 계획 결과

idx_post_status_enddate
스크린샷 2025-05-22 오전 12 03 48

  • 범위 스캔 방식으로 인덱스 활용
  • 필터링 효율: 100%
  • 쿼리 비용: 0.71

idx_post_status_createdat
스크린샷 2025-05-22 오전 12 08 06
image

  • 참조 방식, backward index scan 활용
  • 별도의 filesort 없이 인덱스 스캔으로 정렬 처리

✅ 셀프 체크리스트

  • PR 제목을 형식에 맞게 작성했나요?
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있나요?
  • 테스트는 잘 통과했나요?
  • 빌드에 성공했나요?
  • 본인을 assign 해주세요.
  • 해당 PR에 맞는 label을 붙여주세요.

🙋🏻‍ 확인해주세요

  • yaml 파일에서 flyway 마이그레이션 경로가 누락되어 있어, 기본 경로(classpath:db/migration)를 명시적으로 dev/prod에 대해서 추가했습니다.

🔗 Jira 티켓


https://yappsocks.atlassian.net/browse/YS-440

Summary by CodeRabbit

  • Chores
    • 실험 게시글의 모집 상태 및 종료일, 생성일 컬럼에 대한 데이터베이스 인덱스가 추가되어 관련 조회 성능이 향상되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented May 21, 2025

Walkthrough

이번 변경 사항은 데이터베이스 마이그레이션 스크립트를 통해 experiment_post 테이블에 두 개의 새로운 인덱스를 추가합니다. 각각 recruit_statusend_date, 그리고 recruit_statuscreated_at 컬럼 조합에 대한 인덱스입니다.

Changes

파일/경로 변경 요약
infrastructure/src/main/resources/db/migration/V202505220014__add_index_recruit_status_end_date_and_created_at.sql experiment_post 테이블에 두 개의 복합 인덱스 추가 (recruit_status, end_daterecruit_status, created_at)

Poem

🐇
인덱스 두 개, 번쩍 추가!
토끼는 쿼리 속도에 깡충깡충,
recruit_status로 점프해,
end_date, created_at도 놓치지 않아.
데이터 숲에 길을 내며,
더 빠른 탐험을 꿈꾸네!

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Ji-soo708 Ji-soo708 self-assigned this May 21, 2025
@github-actions github-actions bot changed the title chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 [YS-440] chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 May 21, 2025
@Ji-soo708 Ji-soo708 changed the title [YS-440] chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 [YS-440] feat: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 May 21, 2025
@Ji-soo708 Ji-soo708 added the ✨ FEATURE 기능 추가 label May 21, 2025
@Ji-soo708 Ji-soo708 changed the title [YS-440] feat: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 [YS-440] chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 May 21, 2025
@Ji-soo708 Ji-soo708 added ⚙️ CHORE config, workflow.yaml and removed ✨ FEATURE 기능 추가 labels May 21, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
infrastructure/src/main/resources/db/migration/V202505220014__add_index_recruit_status_end_date_and_created_at.sql (1)

1-2: 인덱스 추가 적절성 및 운영 환경 고려

  • experiment_post 테이블의 recruit_status+end_date, recruit_status+created_at 복합 인덱스 추가는 조회 및 정렬 성능을 크게 향상시킵니다.
  • 다만 중복 인덱스가 없는지 확인하고, 이미 유사한 인덱스(단일 컬럼 인덱스 등)가 존재하지 않는지 검증해 주세요.
  • PostgreSQL 사용 시 서비스 중단을 최소화하기 위해 CREATE INDEX CONCURRENTLY 옵션을,
    MySQL 사용 시 ALGORITHM=INPLACE, LOCK=NONE 옵션을 활용하는 방안을 고려하면 더욱 안전합니다.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4dfbe43 and a4d03a1.

📒 Files selected for processing (1)
  • infrastructure/src/main/resources/db/migration/V202505220014__add_index_recruit_status_end_date_and_created_at.sql (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

@Ji-soo708 Ji-soo708 changed the title [YS-440] chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 [YS-440] chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 May 21, 2025
@Ji-soo708 Ji-soo708 changed the title [YS-440] chore: experiment_post 테이블 조회 최적화를 위한 인덱스 추가 작업 [YS-440] chore: experiment_post 테이블 인덱스 추가 작업 May 21, 2025
@Ji-soo708 Ji-soo708 requested a review from chock-cho May 21, 2025 16:00
Copy link
Member

@chock-cho chock-cho left a comment

Choose a reason for hiding this comment

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

안녕하세요! 지수님 작업 잘 봤어요,,
제 작업이었는데 놓친 부분이었었네요 🥺인덱스 잘 반영해주셔서 감사합니다 🙌
두 복합 인덱스 모두 쿼리 목적에 맞게 잘 설계된 같다는 의견이에요.
filesort 없이 정렬 처리된 점이 좋아보이는데요.

한 가지 궁금한 점이 있는데요!
실행 계획에서 Backward Index Scan이 사용된 걸 처음 봐서요 👀
혹시 일반 Index Scan과 어떤 차이가 있는지, 실제 쿼리 정렬에서 어떤 이점이 있는 건지 간단히 설명해주실 수 있을까요?

(구글링은 해봤는데 감이 잘 안 잡혀서요..! 😅)

좋은 작업 잘봤습니다!

@Ji-soo708
Copy link
Member Author

한 가지 궁금한 점이 있는데요! 실행 계획에서 Backward Index Scan이 사용된 걸 처음 봐서요 👀 혹시 일반 Index Scan과 어떤 차이가 있는지, 실제 쿼리 정렬에서 어떤 이점이 있는 건지 간단히 설명해주실 수 있을까요?

실행 계획에서 Backward Index Scan이 나온 이유는 정렬 방향 때문입니다. created_at을 포함한 복합 인덱스를 만든 이유가 orderBy(getOrderClause(order))로 정렬 방향(ASC/DESC)이 결정되는 구조이기 때문이에요.

인덱스는 기본적으로 오름차순으로 정렬되어 있기 때문에, 제가 실행 계획에서 내림차순 정렬 조건으로 조회를 시도한 것처럼 ORDER BY created_at DESC 같은 쿼리를 실행하면 DB는 인덱스를 역순으로 탐색하게 되고 이걸 Backward Index Scan이라고 해요. 일반 Index Scan탐색 방향만 다를 뿐, 성능상 차이는 없습니다! ☺️

@Ji-soo708 Ji-soo708 merged commit b58b25e into dev May 28, 2025
5 checks passed
@Ji-soo708 Ji-soo708 deleted the chore/YS-440 branch May 28, 2025 14:17
Ji-soo708 added a commit that referenced this pull request Jun 6, 2025
* [YS-415] feature: 연구자 회원 가입 - 인증 번호 메일 전송 시, 요청 횟수 반환 추가 (#137)

* refactor: add requestCount field to notify users of request limit

* fix: resolve CI ktlintCheck fail

* hotfix: fix ktlintCheck failure by formatting code

* [YS-418] fix: 연구자 회원가입 이메일 인증 완료 시, 누락된 인증 요청 횟수 초기화 로직 추가 (#138)

* [YS-440] chore: experiment_post 테이블 인덱스 추가 작업 (#139)

* [YS-457] hotfix: ktlint 버전 문제로 gradle ktlintCheck 방식으로 변경 (#141)

* [YS-459] hotfix: 지역 공고 전체 개수 조회 API 오류 해결 (#142)

* fix: compute total post count for _ALL area based on sub-areas

* test: update tests to reflect _ALL area total count fix

* refactor: refactor area count logic for better readability

---------

Co-authored-by: Sujung Shin <113707388+chock-cho@users.noreply.github.com>
Co-authored-by: 베뉴 <christer10@ewhain.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️ CHORE config, workflow.yaml

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants