Home > database >  MYSQL SQL performance optimization, give some advice
MYSQL SQL performance optimization, give some advice

Time:01-06

EXPLAIN the SELECT
Report_time,
Shop_name,
Order_no,
Rela_money,
(CASE erp_times WHEN 1 THEN the STATUS ELSE - 4 END) AS STATUS
,
Store_money,
Is_same
Order_status,
Warehouse
,
Kd_number
,
Kd_company
,
Product_number
,
Product_name
,
Create_time,
Update_time,
Memo,
ReportTimes AS times,
Store_times AS store_times
The FROM
(
SELECT
CASE
Count (1)
1 THEN the WHEN
Bed. Send_warehouse ELSE GROUP_CONCAT (bed. Send_warehouse SEPARATOR "/")
END AS warehouse,
CASE
Count (1)
1 THEN the WHEN
Bed. Courier_number ELSE GROUP_CONCAT (bed. Courier_number SEPARATOR "/")
END AS kd_number,
CASE
Count (1)
1 THEN the WHEN
Bed. Courier_company ELSE GROUP_CONCAT (bed. Courier_company SEPARATOR "/")
END AS kd_company,
CASE
Count (1)
1 THEN the WHEN
Bed. Product_number ELSE GROUP_CONCAT (bed. Product_number SEPARATOR "/")
END AS product_number,
CASE
Count (1)
1 THEN the WHEN
Bed. Product_name ELSE GROUP_CONCAT (bed. Product_name SEPARATOR "/")
END AS product_name,
Newbb memo,
Newbb report_time,
Newbb shop_name,
Newbb order_no,
Newbb rela_money,
Newbb STATUS,
Newbb store_money,
Newbb. Is_same
Newbb order_status,
Newbb create_time,
Newbb update_time,
Newbb reportTimes,
Newbb store_times AS store_times,
CASE

The WHEN bed. Send_warehouse IS NULL THEN
0 the ELSE count (1)
END AS erp_times
The FROM
(
SELECT
BRD. Remark AS memo,

BRD. Report_time AS report_time
,
BRD. Shop_name AS shop_name
,
BRD. Order_no AS order_no
,
BRD. Buyer_actually_pay_cost AS rela_money
,
BRD. STATUS AS STATUS
,

CASE
Count (1)
1 THEN the WHEN
BSD. Actually_pay ELSE GROUP_CONCAT (BSD) actually_pay SEPARATOR "/")
END AS store_money,
CASE
BSD. Actually_pay
The WHEN BRD. Buyer_actually_pay_cost THEN
The 'TRUE' ELSE 'FALSE'
END AS is_same
,

BSD. Order_status AS order_status
,
BRD. Create_time AS create_time,
BRD. Update_time AS update_time,
BRD. ReportTimes AS reportTimes,
CASE

WHEN the BSD. Order_status IS NULL THEN
0 the ELSE count (1)
END AS store_times
The FROM
(
SELECT
Remark,
Report_time,
Shop_name,
Order_no,
Buyer_actually_pay_cost,
The STATUS,
Create_time,
Update_time,
The dump,
Count (1) the AS reportTimes
The FROM
Biz_report_data
WHERE
1=1
AND report_time>='2020-11-01'
AND report_time <='2020-11-01'
GROUP BY
Order_no
) BRD
LEFT the JOIN biz_store_data BSD ON BRD. Order_no=BSD. Order_no
WHERE
BRD STATUS!=0
GROUP BY
Order_no
) newbb
LEFT the JOIN biz_erp_data bed ON order_no=bed. On_order_no
GROUP BY
Order_no
) groupView
WHERE
1=1
AND order_no IS NOT NULL
AND store_times> 1
GROUP BY
Order_no
The ORDER BY
Report_time ASC
  • Related