DOCS/troubleshooting/251002_db_separation_emotion_data.md
happybell80 b18b7f1143 refactor: 트러블슈팅 파일명 형식 통일
- 8자리 날짜(20251013) → 6자리 날짜(251013)
- 16개 파일 rename 완료
- 형식: yymmdd_주제.md로 통일

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 21:09:56 +09:00

1.3 KiB

DB 분리 구조 및 감정 데이터 저장 현황

발생 일시

2025-10-02

현황

세 개의 분리된 데이터베이스 운영 중

DB 구조

  1. main_db: 핵심 데이터

    • user, conversation_log, gmail_token 등 16개 테이블
    • PostgreSQL 일반 DB
  2. robeing_metrics: 시계열 메트릭

    • emotion_readings 테이블 (TimescaleDB 하이퍼테이블)
    • 감정 데이터 3건 저장 (2025-10-02 12:21~12:27)
  3. rb8001_db: rb8001 전용 DB

감정 데이터 저장 확인

-- robeing_metrics DB에 저장
SELECT * FROM emotion_readings;
-- 결과: 3건 (happiness 2건, anger 1건)

문제점

  • conversation_log가 main_db에 있어 시계열 분석 비효율
  • 감정 시스템 구현했지만 실제 대화 flow 미연동
  • DB 간 JOIN 필요 시 성능 이슈

해결 방안

  1. conversation_log를 robeing_metrics로 이전
  2. user 테이블 주요 컬럼만 robeing_metrics에 읽기 전용 복제
  3. Foreign Data Wrapper로 필요시 크로스 DB 조회

관련 파일

  • /home/admin/rb8001/app/state/database.py: METRICS_DB_URL 환경변수
  • /home/admin/rb8001/app/router/emotion_endpoint.py: robeing_metrics 연결

교훈

  • 용도별 DB 분리는 유지 (성능/백업 전략 차별화)
  • 시계열 데이터는 TimescaleDB 사용
  • 자주 조인하는 데이터는 복제 고려