-- 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);
