Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    74

    Unanswered: Which can give better performance ? Union or Select

    Good day All,

    i wonder in following sample, which give better performance and why ?

    Selection :
    Code:
    Select A.column 
     (Select columnB where table_B where condition) AS columnB
    FROM table_A A
    Code:
    Select A.column, 
    NULL as ColumnB, 
    FROM table_A
    
    UNION
    Select null as columnA,
    B.column as ColumnB, 
    FROM table_B B
    In above sample, which actually give a better performance ? and any specific reason ?

    i wish to learn performance tuning, is there any good reference or booko on this topic ? appreciated your guidance in advance

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Well....
    neither of them will actually compile.
    nor would either of them return the same results if you did get them to compile.
    and I suspect you probably want to do neither of these.

    I would start by looking at JOIN syntax, as well as the difference between UNION and UNION ALL.

    EDIT - removed the reference to INNER JOINs - now just referring to JOINs in general
    Last edited by pootle flump; 10-15-08 at 11:57.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •