-- Indexes for orders table CREATE INDEX IF NOT EXISTS idx_orders_product_date ON orders(product_id, date); CREATE INDEX IF NOT EXISTS idx_orders_date ON orders(date); -- Indexes for purchase_orders table CREATE INDEX IF NOT EXISTS idx_po_product_date ON purchase_orders(product_id, date); CREATE INDEX IF NOT EXISTS idx_po_product_status ON purchase_orders(product_id, status); CREATE INDEX IF NOT EXISTS idx_po_vendor ON purchase_orders(vendor); -- Indexes for product_metrics table CREATE INDEX IF NOT EXISTS idx_metrics_revenue ON product_metrics(total_revenue); -- Indexes for stock_thresholds table CREATE INDEX IF NOT EXISTS idx_thresholds_category_vendor ON stock_thresholds(category_id, vendor); -- Indexes for product_categories table CREATE INDEX IF NOT EXISTS idx_product_categories_both ON product_categories(product_id, category_id);