vertica

DB

[DB] Decode vs Case when

Decode decode(target_col,null,null,0,0,coalesce(target_col2 / target_col, 0)) Case whencase when target_col1 IS NULL then null when target_col1 = 0 then 0 when (target_col1 is null and target_col1 != 0) then coalesce(target_col2 / target_col1,0) ELSE ....  1. 대규모 데이터 및 복잡한 쿼리인 경우 Case when의 속도가 더 빠름.2. Case 문은 statement 이고 decode 는 func에 해당한다. 3. Case 는 sql / pl/sql 모두 쓰이나, deco..

DB

[DB] VERTICA ifnull coalesce

https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Functions/Null/IFNULL.htm IFNULL www.vertica.com if null 을 통한 Null처리보다 coalesce 가 더 일반적인 표준이라고 한다. 회사에서 쓰는 쿼리로 테스트 했을 때 1분 50초가 걸리던 쿼리를 40초로 앞당겼으므로, 약 1분 정도 당겼다. 사용법 : 1. IFNULL ifnull(x.temp,0) as TEMP 2. COALESCE COALESCE(x.temp, x.temp2, x.temp3, x.temp4 ... ) as TEMP2, IFNULL은 되도록 사용 자제 할 것.

girin_dev
'vertica' 태그의 글 목록