Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some general questions about UNION ALL

Status
Not open for further replies.

tbtcust

Programmer
Oct 26, 2004
214
US
Hi all. Questios:

Is there a limitation on the number of UNION ALL in a single query?

Is there a performance impact using UNION ALL?

Is there a better or preferred way of selecting the data?

Thanks in advance for any help.
 
UNION ALL often has less performance implications than UNION, as UNION uses sort to remove duplicates, where UNION ALL doesn't.

Cheers
Greg
 
Thanks Greg. Do you know if there is a limitation on the number of UNION ALL in a query? I found a post that said 16 was the Limit. However I have not been able to confirm that for the latest version of DB2. Thanks again.
 
tbt103,
I just ran

SELECT IBMREQD
FROM "SYSIBM".SYSDUMMY1
UNION ALL
repeated n times

in my v8 QMF. Started off with 16 UNION ALLs and kept going until it didn't like it any more. It got up to 512 ok, but on 513 it gave me the error:
"Your query is too long or too complex."

It may be that 512 is NOT the limit of UNION ALL, but just that the number of characters in the SQL statement is too many. I know that in the past I have had a problem with very large SQL statements giving this sort of error.

Sorry that I can't be any clearer.

Marc
 
Thanks MarcLodge. That helps a lot. I think if there is a limitation, it would be with the length of the query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top