v2_order 表中o_id是主键,o_outstock_time有索引,但如下不会用索引:
SELECT o_move_order_time,o_mask_depart,o_id FROM v2_order WHERE o_outstock_time>1441209600 and o_outstock_time< 1441620000 GROUP BY o_id ORDER BY o_id DESC LIMIT 0,50
但去掉limit会有:
SELECT o_move_order_time,o_mask_depart,o_id FROM v2_order WHERE o_outstock_time>1441209600 and o_outstock_time< 1441620000 GROUP BY o_id ORDER BY o_id DESC
去掉order或group也有:
SELECT o_move_order_time,o_mask_depart,o_id FROM v2_order WHERE o_outstock_time>1441209600 and o_outstock_time< 1441620000 LIMIT 0,50
解决方案:10分
解决方案:10分
以文本方式贴出
explain select …
show index from ..
以供分析。