# Database Scaling Strategy ## Sharding & Partitioning Roadmap --- ## 1. Table Partitioning (Stage 3) Historical tables (`orders`, `inventory_ledger`, `outbox_events`) enforce MySQL `RANGE` partitioning by year/month: ```sql ALTER TABLE orders PARTITION BY RANGE (YEAR(created_at)) ( PARTITION p2025 VALUES LESS THAN (2026), PARTITION p2026 VALUES LESS THAN (2027), PARTITION p2027 VALUES LESS THAN (2028), PARTITION pmax VALUES LESS THAN MAXVALUE ); ``` --- ## 2. Horizontal Sharding Evaluation (Stage 4) If catalog or order traffic exceeds single-cluster limits: * **Vitess Integration**: Vitess proxy handles distributed query routing over multiple MySQL shards. * **Shard Keys**: `customer_id` for orders/carts; `category_id` for catalog items.