标签:
数据表dh_order_detail 里一共有169247条数据
原始SQL
SELECT FROM_UNIXTIME(order_time, '%H:%i') 'time', city, district, LEFT (company, 6) company, goods_num, order_price, order_code, order_time FROM dh_order_detail WHERE province_id = 16 GROUP BY order_code ORDER BY order_time DESC LIMIT 50
改进,将GROUP BY外移
SELECT * FROM ( SELECT FROM_UNIXTIME(order_time, '%H:%i') 'time', city, district, LEFT (company, 6) company, goods_num, order_price, order_code, order_time FROM dh_order_detail WHERE province_id = 16 ORDER BY order_time DESC LIMIT 50 ) o GROUP BY order_code运行时间0.049秒
标签:
原文地址:http://blog.csdn.net/szy361/article/details/44341691