Published Jan 22, 2021
[
 
]
query1
UNION
query2
query1 and query2 are fast queries, but the UNION
one is slow
A UNION
(which is the same as UNION DISTINCT
) or a UNION ALL
causes a
temporary table to be created. For UNION
, the table is created with an index
so that duplicates can be removed. With UNION ALL
, there is no index.