Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Problem with UNION

Author  Topic 

sqldev6
Starting Member

18 Posts

Posted - 2008-03-03 : 07:01:26
Hi All,

We have one query like......

Select * from table1
UNION
Select * from table2

When I am excuting this query, its excuting very slow.

But when I am excuting individual queries I am getting results with in 5 seconds.

What would be the causes for thsi query....

Thanks in advance......

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-03 : 07:04:18
UNION, of course. What do you think UNION does?
It sorts out all duplicate records from BOTH resultsets.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-03 : 07:04:45
If you are sure no duplicates exists between the two queries, use

UNION ALL

instead.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sqldev6
Starting Member

18 Posts

Posted - 2008-03-03 : 07:33:33
I tried with UNION ALL, even though its running slowly....
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-03 : 08:50:25
sqldev6 -- do you think you have given us enough information for us to help you troubleshoot?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -