what is the difference between union and union all
Answer Posted / vishal
UNION removes duplicates, whereas UNION ALL does not.
In order to remove duplicates the result set must be
sorted, and this may have an impact on the performance of
the UNION, depending on the volume of data being sorted,
and the settings of various RDBMS parameters ( For Oracle
PGA_AGGREGATE_TARGET with WORKAREA_SIZE_POLICY=AUTO or
SORT_AREA_SIZE and SOR_AREA_RETAINED_SIZE if
WORKAREA_SIZE_POLICY=MANUAL ).
Basically, the sort is faster if it can be carried out in
memory, but the same caveat about the volume of data
applies.
Of course, if you need data returned without duplicates
then you must use UNION, depending on the source of your
data.
I would have commented on the first post to qualify the "is
much less performant" comment, but have insufficient
reputation (points) to do so.
| Is This Answer Correct ? | 9 Yes | 1 No |
Post New Answer View All Answers
How is data stored in sql?
What is your daily office routine?
Which table is left in left join?
What is the difference between sql, mysql and sql server?
What is natural join in sql?
What is a schema? How is it useful in sql servers?
How do you use a while loop in pl sql?
Why is pl sql needed?
What is the difference between join and natural join?
How do you remove duplicates without using distinct in sql?
How to write a query to show the details of a student from students table whose
Can we commit in trigger?
what is data integrity? : Sql dba
Write the command to remove all players named sachin from the players table.
How do I run a script in sql developer?