如何减少执行时间?

时间:2016-03-10 09:49:49

标签: php mysql

这是员工销售视图查询的片段。

CREATE OR REPLACE VIEW EMPLOYEE
AS
SELECT
    customer.`Customer Name`,
    customer.cid,
    city_code.Dist_ID,
    terretory.Executive,
    terretory.Manager1,
    terretory.Manager2,
    district.Dist_Name,
    SUM(item.Sales_Amount) As Sales_Amount
FROM customer
INNER JOIN city_code
    ON city_code.City_id=customer.City_id
INNER JOIN district
    ON district.Dist_Id=city_code.Dist_ID
INNER JOIN terretory
    ON terretory.District_ID=district.Dist_Name
INNER JOIN sales_invoice
    ON sales_invoice.CID=customer.cid
INNER JOIN sales_item
    ON sales_item.Invoice_Number=sales_invoice.Invoice_Number
GROUP BY customer.`Customer Name`

选择操作需要2-3分钟。如何减少执行时间?表格中有超过100,000行。

这是Explain查询结果 enter image description here

0 个答案:

没有答案