DB

[DB] VERTICA ifnull coalesce

girin_dev 2024. 2. 29. 15:28
728x90
반응형

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은 되도록 사용 자제 할 것. 

320x100
반응형