Files
cloud-orchestrator/performance-indexes.sql
kappa ceb5eb7248 refactor: High/Medium 품질 이슈 개선
1. CONFIG 상수 추출
   - Rate limit, Currency, Bandwidth, AI, Cache 설정 중앙화
   - 매직 넘버 10개 → CONFIG 참조로 변경

2. 미사용 함수 제거
   - queryVPSBenchmarks 함수 삭제 (52줄)

3. 에러 타입 체크 개선
   - catch 블록에서 unknown 타입 사용
   - err.message 접근 전 instanceof 체크

4. 쿼리 병렬화
   - queryCandidateServers + queryVPSBenchmarksBatch 병렬 실행
   - 예상 15-25% 응답 시간 개선

5. Use Case 패턴 통합
   - USE_CASE_CONFIGS로 중복 제거
   - getDauMultiplier, getActiveUserRatio 간소화
   - 50줄 이상 중복 코드 제거

6. DB 성능 인덱스 추가
   - instance_types(provider_id, vcpu, memory_mb)
   - pricing(instance_type_id, region_id)
   - regions(region_code, country_code)
   - vps_benchmarks 관련 인덱스

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 16:19:31 +09:00

27 lines
1007 B
SQL

-- Performance indexes for server-recommend
-- Run these on the cloud-instances-db D1 database
-- instance_types: Optimize filtering by provider and specs
CREATE INDEX IF NOT EXISTS idx_instance_types_provider_specs
ON instance_types(provider_id, vcpu, memory_mb);
-- pricing: Optimize joins with instance_types and regions
CREATE INDEX IF NOT EXISTS idx_pricing_instance_region
ON pricing(instance_type_id, region_id);
-- pricing: Optimize price-based sorting
CREATE INDEX IF NOT EXISTS idx_pricing_price
ON pricing(monthly_price_retail, monthly_price_krw);
-- regions: Optimize region code lookups
CREATE INDEX IF NOT EXISTS idx_regions_codes
ON regions(region_code, country_code);
-- vps_benchmarks: Optimize spec-based lookups
CREATE INDEX IF NOT EXISTS idx_vps_benchmarks_specs
ON vps_benchmarks(vcpu, memory_gb, provider_name);
-- vps_benchmarks: Optimize performance queries
CREATE INDEX IF NOT EXISTS idx_vps_benchmarks_performance
ON vps_benchmarks(geekbench_single DESC, monthly_price_usd);