mysql查詢超慢
SELECT a.`order_id` , a.`delivery_date` , a.`buyer_name` , a.`order_status` , a.`account` , a.`delivery_warehouse`
FROM `Sale_Order` a
LEFT JOIN `Sale_Order_de` b ON a.`order_id` = b.`order_id`
GROUP BY a.`order_id`
ORDER BY find_in_set( a.`order_status` , '4,1,5,6,2,0,7' )
以上查詢很慢,需要3-5秒,為什麼用left join因為我還要有篩選條件的,現在不加條件都超慢
explain結果:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a ALL NULLNULLNULLNULL38472 Using temporary; Using filesort
1 SIMPLE b ref OrderId,order_id,order_id_2,order_id_3,order_id_4,order_id_5,order_id_6 OrderId 152 demo.a.order_id 1 Using index