这两个 View 中的哪一个需要更少的CPU?
我目前正在检查某些 View 的句子,并且需要知道如果用双管道替换concat函数,性能是否会有所提高。
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
最佳答案
The CONCAT function is identical to the CONCAT operator. For more information, see With the concatenation operator.
因此,明确的答案是:它们是相同的。但是,IBM确实有这样的说法:
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.
关于performance - DB2 concat与双管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15231631/