案例四
-
--4.1 bad
-
select count(*) from (select name from old union select name from new);
-
-
COUNT(*)
-
----------
-
1000000
-
-
Elapsed: 00:00:20.76
-
-
--4.2 good
-
select count(*) from (select name from old union all select name from new);
-
-
COUNT(*)
-
----------
-
1000000
-
-
Elapsed: 00:00:05.53
结论:如果可以使用UNION
ALL就不要使用UNION
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/17013648/viewspace-1072422/
,如需转载,请注明出处,否则将追究法律责任。