如何优化和加速当前的Magento SQL查询?

时间:2017-12-11 07:52:22

标签: sql magento-1.9

如何优化当前的Magento SQL查询?

SELECT​ ​ customer_entity.email,​ ​ COUNT(sales_flat_order.increment_id)
AS​ ​ number_of_orders
FROM​ ​ customer_entity
LEFT JOIN​ ​ sales_flat_order​ ​ ON​ ​ sales_flat_order.customer_email​ ​ =
customer_entity.email
GROUP​ ​ BY​ ​ customer_entity.email
ORDER​ ​ BY​ ​ number_of_orders​ ​ DESC;

1 个答案:

答案 0 :(得分:-1)

如果customer_email存在于同一个表中,为什么即使进行加入?

SELECT `customer_email`, COUNT(increment_id) as number_of_orders 
FROM `sales_flat_order` 
GROUP BY customer_email 
ORDER BY number_of_orders DESC;