查询很慢
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 NULL NULL NULL NULL 38472 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
索引我都加了的,
find_in_set( a.`order_status` , '4,1,5,6,2,0,7' ) 这个有没有另的办法?我只想4,1排前面就行了