From d83cf2ddac694b7337f096bfe757bd81650f2111 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Thu, 2 Oct 2025 14:30:53 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8A=B8=EB=9F=AC=EB=B8=94=EC=8A=88=ED=8C=85:?= =?UTF-8?q?=20DB=20=EB=B6=84=EB=A6=AC=20=EA=B5=AC=EC=A1=B0=20=EB=B0=8F=20?= =?UTF-8?q?=EA=B0=90=EC=A0=95=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=ED=98=84=ED=99=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 세 개 DB 분리 운영 (main_db, robeing_metrics, rb8001_db) - emotion_readings는 robeing_metrics에 정상 저장 (3건) - conversation_log 시계열 이전 필요 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../20251002_db_separation_emotion_data.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 troubleshooting/20251002_db_separation_emotion_data.md diff --git a/troubleshooting/20251002_db_separation_emotion_data.md b/troubleshooting/20251002_db_separation_emotion_data.md new file mode 100644 index 0000000..a1a1bad --- /dev/null +++ b/troubleshooting/20251002_db_separation_emotion_data.md @@ -0,0 +1,44 @@ +# 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 + +### 감정 데이터 저장 확인 +```sql +-- 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 사용 +- 자주 조인하는 데이터는 복제 고려 \ No newline at end of file