Generally speaking, the performance of sub-queries and associated sub-tables is better than that of associated tables;
1. When connecting to the left, put the table with filter conditions in the front
2. Use the field name instead of *
sql statement 1:
SELECT p.pay_state payState, o.posting_date postingDate, o.amount amount, o.poundage poundage, s.sp_id spId, s.sp_code spCode, s.name spName, wu.user_id userId, wu.user_name userName, cp.product_code productId, cp.name productName FROM t_pdss p LEFT JOIN orfr o ON p.order_id = o.order_id LEFT JOIN spee s ON o.account_id = s.sp_id LEFT JOIN prdsct cp ON o.product_id=cp.product_code LEFT JOIN web wu ON s.sales_user_id = wu.user_id WHERE o.posting_date = 20160922;
sql statement 2:
SELECT p.pay_state pay_state, p.channel_cost channel_cost, o.posting_date posting_date, o.amount amount, o.poundage poundage, s.sp_id sp_id, s.sp_code sp_code, s.name sp_name, wu.user_id user_id, wu.user_name user_name, c.channel_id channel_id, c.channel_name channel_name FROM (SELECT posting_date,amount,poundage,order_id,account_id FROM t_orfr WHERE posting_date = 20160922) o LEFT JOIN pdss p ON p.order_id = o.order_id LEFT JOIN spee s ON o.account_id = s.Fsp_id LEFT JOIN prdsct cp ON o.product_id=cp.product_code LEFT JOIN web wu ON s.sales_user_id = wu.user_id
Statement 2 is faster than Statement 1