NexaCommerce's analytics dashboard is timing out during Black Friday peak traffic. Four queries hit a 12M-row orders table and are breaching the 80ms SLA. The previous DBA left a mess of redundant and missing indexes. No hints — diagnose and fix it yourself.
SHOW INDEX FROM orders/order_items/customers/productsEXPLAIN ANALYZE on each problem queryUSE INDEX(idx_name) or FORCE INDEX where MySQL chooses wrongNo syntax templates provided. You must reason from first principles about which columns belong in the index and in what order. The covering index for Q1 is non-obvious — the key insight is the join order and which table drives the scan.
SHOW INDEX FROM <table>EXPLAIN ANALYZE SELECT ...CREATE INDEX idx_name ON table(col1, col2, col3)DROP INDEX idx_name ON tableSELECT ... FROM t USE INDEX(idx_name) WHERE ...SHOW PROFILE FOR QUERY 1SELECT * FROM sys.schema_redundant_indexes