-- 高频打手订单、拼单统计、快手回调扫描和仪表盘查询的索引保护。
CREATE INDEX IF NOT EXISTS idx_work_order_shares_order_status_include_quantity
  ON work_order_shares(work_order_id, status) INCLUDE (quantity);

CREATE INDEX IF NOT EXISTS idx_work_order_events_order_type
  ON work_order_events(work_order_id, event_type);

CREATE INDEX IF NOT EXISTS idx_fulfillment_tasks_status_updated_at
  ON fulfillment_tasks(task_status, updated_at DESC);

CREATE INDEX IF NOT EXISTS idx_kuaishou_industry_vouchers_callback_retry_order
  ON kuaishou_industry_vouchers(COALESCE(send_callback_sent_at, created_at), id)
  WHERE send_callback_status <> 'success';
