我有一個大約200個表的mysql db &每個表都有大約40,000個條目。 我嘗試了內部連接,但是在xamp環境下,大約需要4小時 ...以及在雲上,它只會在10分鐘後給出錯誤500。 這裏是查詢mysql卡在內連接查詢
SELECT DISTINCT od.io_id, od.io_date, sm.style_code, cm.short_name, od.cust_po, od.mepl_no, od.season, btm.cat_art_no, odd.rev_del_date, od.total_qty, od.shipping_qty, um.short_name, od.order_value_fc, od.order_value_inr, odd.ex_factory_date, od.repeat_order, ot.order_type_name, od.agent_commission AS return_bonus, cm.bonus_discount, cm.other_discount, od.status, il.short_name AS terms, delm.delivery_mode_name, c.short_name AS cur
FROM orderdetails od
INNER JOIN bomtrimqty btm ON od.style_id = btm.style_id
INNER JOIN orderdeliverydetails odd ON od.io_no = odd.io_no
INNER JOIN ordertype ot ON od.order_type_id = ot.order_type_id
INNER JOIN stylemaster sm ON od.style_id = sm.style_id
INNER JOIN customermaster cm ON od.customer = cm.customer_id
INNER JOIN unitmaster um ON um.unit_id = sm.unit_id
INNER JOIN deliverymodelist delm ON delm.delivery_mode_id = odd.rev_del_mode
INNER JOIN incotermlist il ON il.inco_term_id = od.order_type_id
INNER JOIN currency c ON od.fc_unit = c.currency_id
ORDER BY od.io_id DESC
即使我試圖
GROUP BY od.io_id DESC
LIMIT 10
,但沒有運氣.... mysql的犯規給任何錯誤.. 請幫我出這
Thx提前!
你有加入所有列的索引嗎?還有一個關於'orderdetails.io_id'的索引? – Barmar
同意@Barmar - 這可能是與某些列缺少索引有關的問題。 – Cyclonecode
我建議由於腳本時間限制500錯誤...檢查php error_reporting設置以獲取更多信息.. – simialbi