2
只想問問哪些需要更多時間。查詢時間執行
舉例如下場景:
SELECT *
FROM
(SELECT *
FROM t1
WHERE [Date] BETWEEN "20151012" AND "20151018"
UNION ALL
SELECT *
FROM t2
WHERE [Date] BETWEEN "20151012" AND "20151018"
UNION ALL
SELECT *
FROM t3
WHERE [Date] BETWEEN "20151012" AND "20151018"
) AS T
或本聲明:
SELECT *
FROM
(SELECT * FROM t1
UNION ALL
SELECT * FROM t2
UNION ALL
SELECT * FROM t3) AS T
WHERE
[Date] BETWEEN "20151012" AND "20151018"
非常感謝!
大機會他們會表現相同...你不能檢查? –
使用EXPLAIN來檢查執行計劃或實際運行查詢。 –
第一個查詢不需要外部'SELECT * FROM',它只是多餘的。就查詢執行時間而言,它取決於不同的因素(表格的大小,每個表上的索引等)。試試拉馬先生的建議,看看執行計劃的樣子。 –