• it depends :-), but both queries could return different results when are used with real tables.

    Your  first query (with UNION ALL) could return duplicates, when you have the same ids in the first and second subquery (e.g. when you add a (2) into the value list after the (5)). The second query (with UNION) would eliminate this duplicates too.

    So it is not valid to compare the performance, since you are comparing different (but similar) things.

    PS:  if you are SURE, that there are only different IDs in both subqueries, the UNION ALL query would be slightly faster, since it is easier to eliminate duplicates in a e.g. 10 and another 20 items list, than in a 30 items list (in a 10 item list, you have to compare the first with the second until the 10th, the second value with 3rd until 10th and so on, so you have 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 = 45 possible combinations; in a 20 items list there are 209 combinations and in a 30 items list 464)

    God is real, unless declared integer.