perf: SQL 로깅 상시화 해제 + channel_videos 인덱스 추가

느려짐의 유력 원인 두 가지를 정리한다.
1) p6spy가 모든 SQL을 파라미터값 포함해 매번 로깅하던 것을 기본 OFF로.
   디버깅 시 P6SPY_LOGGING=true 로 켠다.
2) channel_videos에 인덱스가 하나도 없어 데이터가 늘면 풀스캔이었다.
   리포지토리의 실제 필터/정렬 컬럼에 인덱스 추가(ddl-auto가 자동 생성):
   video_id, channel_id, interest_status, source, category_id,
   published_at, views_per_sub_ratio

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
hehihoho3@gmail.com 2026-07-23 15:13:55 +09:00
parent f22f7028c4
commit d0faada002
2 changed files with 11 additions and 2 deletions

View File

@ -10,7 +10,15 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
@Entity
@Table(name = "channel_videos")
@Table(name = "channel_videos", indexes = {
@Index(name = "idx_cv_video_id", columnList = "video_id"), // 조회/중복스킵 lookup
@Index(name = "idx_cv_channel_id", columnList = "channel_id"), // 채널별 영상
@Index(name = "idx_cv_interest_status", columnList = "interest_status"), // 큐레이션/칸반 필터·집계
@Index(name = "idx_cv_source", columnList = "source"), // 출처 필터·집계
@Index(name = "idx_cv_category_id", columnList = "category_id"), // 카테고리 필터·집계
@Index(name = "idx_cv_published_at", columnList = "published_at"), // 게시일 정렬·발굴 필터
@Index(name = "idx_cv_views_per_sub_ratio", columnList = "views_per_sub_ratio") // 떡상 배율 정렬(발굴/후보)
})
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ChannelVideo {

View File

@ -26,7 +26,8 @@ spring:
decorator:
datasource:
p6spy:
enable-logging: true
# 운영 기본 OFF — 모든 SQL 로깅은 순수 오버헤드. 디버깅 시 P6SPY_LOGGING=true 로 켠다.
enable-logging: ${P6SPY_LOGGING:false}
multiline: true
logging: slf4j
log-message-format: com.hlab.yanalyst.global.config.P6SpyFormatter