Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DB2 concat vs double pipe

Which one of this two views require less CPU?

I'm currently checking the sentences of some views and need to know if there is some performance improvement if concat functions are replaced by double pipes.

create view VIEW1 as
select concat(concat(concat(concat(concat(concat(concat(concat(concat(A, B),C),D),E),F),F),G),H),I) from TABLE

create view VIEW2 as
select A||B||C||D||E||F||G||H||I from TABLE
like image 854
Julius Avatar asked Mar 05 '13 18:03

Julius


2 Answers

From Information Center:

The CONCAT function is identical to the CONCAT operator. For more information, see With the concatenation operator.

So, the definitive answer is: they're the same. However, IBM does have this to say:

Vertical bars (or the characters that must be used in place of vertical bars in some countries) can cause parsing errors in statements passed from one DBMS to another. The problem occurs if the statement undergoes character conversion with certain combinations of source and target CCSIDs. Thus, CONCAT is the preferable concatenation operator.

like image 89
bhamby Avatar answered Oct 17 '22 12:10

bhamby


I don't think there will be performance difference, but using pipes-makes it easier to read.

like image 1
Sathy Sannasi Avatar answered Oct 17 '22 11:10

Sathy Sannasi