SELECT cus.cust_id, cus.cust_name, cus.cust_lastname, cus.cust_zip,
cus.cust_city, cus.cust_phone, cus.cust_email, cus.status,
cus.cust_from, cus.cust_by, cus.added_date, zip.zipcode AS zipcode_val,
COUNT(ord.customer_id) AS custTotalOrders
FROM customers AS cus
LEFT JOIN orders AS ord ON cus.cust_id = ord.customer_id
LEFT JOIN zipcodes AS zip ON cus.cust_zip = zip.zip_id
WHERE cus.cust_id IS NOT NULL AND cus.cust_email IS NOT NULL
GROUP BY cus.cust_id, cus.cust_email
ORDER BY cus.added_date DESC
customers表有69529条记录
订单表有295884条记录
zipcodes表有1257条记录
以上查询执行时间超过200秒/正在进行加载.......
如何优化以上查询?
如何解决这个问题? 有人帮我吗?
提前致谢