SELECT * FROM ( (SELECT table1.id1, table1.id1_type AS id1, FROM child AS table2 STRAIGHT_JOIN parent AS table1 ON table1.id1=table2.id1 AND table1.id2=table2.id2 AND table1.time=table2.time WHERE table1.id1=123456 AND ((table1.time>=0 AND table1.time<=1361936895))) UNION ALL (SELECT table1.id1 AS id1, table1.id1_type FROM child AS table2 STRAIGHT_JOIN step_parent AS table1 ON table1.id1=table2.id1 AND table1.id2=table2.id2 AND table1.time=table2.time WHERE table1.id1=123456 AND table1.time<=1361936895)))) AS T WHERE id1_type NOT IN (15) ORDER BY time DESC LIMIT 2000
我正在使用下面的sql查詢(兩個連接,一個union all),我看到裏面增加了連接後大量增加了延遲。我可以看到存儲空間的使用情況在我的機器上出現,我想知道是否因爲我正在創建臨時表?
作爲附加上下文,當我添加連接時,我還添加了'table1','table2'別名,以便在選擇列時避免模糊性,我開始看到這些空間使用率增加。
爲什麼這另外,或查詢作爲一個整體,是造成這些查詢巨大的存儲秒殺任何建議,將不勝感激:)
什麼數據庫引擎? – 2013-03-14 04:16:19
'STRAIGHT_JOIN'暗示MySQL – msmucker0527 2013-03-14 17:21:06