Re: Query using Union: performance
Posted in 1996
cseoanem@wport.com (Carlos Seoane) wrote: :Hi, :I want to retrieve information from two identical tables, one is :current info and the other one has historical information. I am doing :a query of both tables using a UNION, with two identical SELECT, but :refering each one to a different table. :My question is: what about the performance?. Is there a better way to :do this?. If UNION is what you want there is no better way. You should be aware of the difference between a UNION and UNION ALL of course. Although you (hopefully) don't need UNION ALL, using it *may* give you better performance. The engine won't have to exclude duplicates. Although you know there are non, the engine probably don't, so it may do extra work to make sure it excludes any possible duplicates. If you have an order by clause this *may* not be any extra work for the engine. I don't know exactly how it does such duplicate exclusion internally. You will have to test this. Nils.Myklebust@ccmail.telemax.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company