以下是示例:
SELECT <columns>
FROM (..........<subquery>..........) AS xxx
INNER JOIN(s) with xxx.............
LEFT OUTER JOIN(s) with xxx........
WHERE <filter conditions>
如果我错了,请纠正我:
<subquery>
是派生表吗? (
SELECT * FROM A UNION ALL
SELECT * FROM B UNION ALL
SELECT * FROM C...
) AS xxx
left outer join T with xxx
和
SELECT * FROM A
LEFT OUTER JOIN T ...
WHERE....
UNION ALL
SELECT * FROM B
LEFT OUTER JOIN T ...
WHERE....
UNION ALL
SELECT * FROM C
LEFT OUTER JOIN T ...
WHERE....
答案 0 :(得分:2)
在每个案例中,值得查看您的查询执行计划并找到痛点。当他们可以进行搜索时,查找正在进行扫描的事物,这通常会给你带来显着的提升。事情是扫描而不是寻求:
WHERE function(field) = value
)但问题的底线答案是 - 不,如果您单独选择派生表,则不应担心派生表会包含大量数据。