|
Archives of the TeradataForumMessage Posted: Fri, 25 Feb 2005 @ 08:33:57 GMT
Narayan Murthy wrote:
If you rewrite intersect/union with and/or it's usually more efficient: - two accesses to the base table vs. one access - distinct vs. no distinct I usually recommend union/intersect/except only if the data is from different tables. On some rare cases when set operations may be more efficient, but you have to EXPLAIN... There's only one case when union is always better, a OR-ed join condition: select from t1 join t2 on t1.col1 = t2.col1 OR t1.col1 = t2.col2 This will *always* result in a product join, so rewrite as select from t1 join t2 on t1.col1 = t2.col1 union [all] select from t1 join t2 on t1.col1 = t2.col2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright 2016 - All Rights Reserved | |||||||||||||||||||||||||||||||||||||||||||||||||||
Last Modified: 15 Jun 2023 | |||||||||||||||||||||||||||||||||||||||||||||||||||