1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Union or Outer Join

Discussion in 'SQL PL/SQL' started by jagadekara, Dec 26, 2014.

  1. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Hi All,

    In Sql query performance wise which is better Union or Outer Join?
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi.

    No uniform response to your question..

    not absolutely correctly simple to compare different methods of join/combining of data...

    note:
    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).
     
  3. ocprep

    ocprep Forum Advisor

    Messages:
    277
    Likes Received:
    76
    Trophy Points:
    410
    Location:
    Orlando, Florida
    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.