Discussion in 'SQL PL/SQL' started by jagadekara, Dec 26, 2014.
In Sql query performance wise which is better Union or Outer Join?
No uniform response to your question..
not absolutely correctly simple to compare different methods of join/combining of data...
There is a possibility full outer join and union will return same number of rows, but number of columns will never be the same. If table a has N columns and table b has M columns, full outer join (same as any other join) will have NM columns while union will have N columns (and N must be equal to M, otherwise union is not possible).
As with any such question, the only truly defensible answer is 'It depends'. I am certain that it would be possible to make one test case that would make a Outer Join faster than a set operation and a second test case that would show the set operation being faster than an Outer join. Mind you -- in order to make that test case obviously faster, the number of rows would have to be significant.
Generally, the best solution is to get empirical evidence. Try the query both ways and time the results.