PS: Union all will make no difference unless routes are duplicate.
... other than eliminating an unneccessary sort of the data set, which I'd regard as being pretty important. UNION ALL ought to be the first recourse, and UNION should only be used where there is a specific requirement to make the result set distinct.
Do you roll your eyes at colleagues in meetings? Nice touch.
--> after the union command:
mon1 mon2 mon2 mon1
mon2 mon3
mon3 mon5
mon5 mon2
--> but it's very important that the order is the same as the original, because afterwards some other activities are done.
If you want order then mark each set of the result with a flag to indicate which column pair it came from -- ordering the result set by pair number would then be possible. Don't rely on the set being ordered without applying an ORDER BY.
Bookmarks