我在mysql数据库中有以下查询,执行它需要1.9秒,我想让它运行得更快
select
1 AS `auto`,
`stock2`.`PhoneModal_Name` AS `PhoneModal_Name`,
`stock2`.`Rate` AS `Rate`,
(sum(`stock2`.`Quantity_take`) - sum(`stock2`.`Quantity_give`)) AS `balance`,
`stock2`.`Unit_Name` AS `Unit_Name`,
`stock2`.`STORE_NAME` AS `STORE_NAME`,
`stock2`.`PhoneModal_No` AS `PhoneModal_No`,
((1 / 1) / 2018) AS `orderdate`,
sum(`stock2`.`Quantity_take`) AS `take`,
sum(`stock2`.`Quantity_give`) AS `give`
from
`stock2`
group by `stock2`.`PhoneModal_Name` , `stock2`.`Rate` , `stock2`.`Unit_Name` ,
`stock2`.`STORE_NAME` , `stock2`.`PhoneModal_No`
1条答案
按热度按时间plupiseo1#
请确保在stock2上为groupby中的列创建了一个复合索引