Update Query Optimization

General
Teradata Employee

Update Query Optimization

Hi, All. I have an update query where in it causes a 98 percent CPU Skew. The  core table has good PI and not skewed. but when i joined to a NON PI table. The CPU SKEW arises.

Can anyone here simplify this query?

CURRENT VALIDTIME 

UPDATE A

    FROM HRCP_CORE_T.RACDETFL A,

        HRCP_STAGE_HERC_T.AS4HRCCP_WSDATA_RACDETFL B 

SET RDLOC = B.RDLOC 

, RDCATG = B.RDCATG , RDCLAS = B.RDCLAS , RDSUBC = B.RDSUBC 

, RDITEM = B.RDITEM , RDSTKC = B.RDSTKC , RDQTY = B.RDQTY 

, RDQTYR = B.RDQTYR , RDCUS# = B.RDCUS# , RDDLST = B.RDDLST 

, RDDL# = B.RDDL# , RDOVR = B.RDOVR , RDMHCD = B.RDMHCD , RDMHO = B.RDMHO 

, RDMHI = B.RDMHI , RDMICG = B.RDMICG , RDHRRT = B.RDHRRT 

, RDMNRT = B.RDMNRT , RDDYRT = B.RDDYRT , RDWKRT = B.RDWKRT 

, RDMORT = B.RDMORT , RDDWP = B.RDDWP , RDDWD = B.RDDWD , RDDWW = B.RDDWW 

, RDDWM = B.RDDWM , RDPRCE = B.RDPRCE , RDUNIT = B.RDUNIT 

, RD#RTN = B.RD#RTN , RDDATO = B.RDDATO , RDTIMO = B.RDTIMO 

, RDDATI = B.RDDATI , RDTIMI = B.RDTIMI , RDSTTS = B.RDSTTS 

, RDDSCP = B.RDDSCP , RDDSC$ = B.RDDSC$ , RDCOST = B.RDCOST 

, RDCOM = B.RDCOM , RDTAX = B.RDTAX , RDRSNC = B.RDRSNC , RDRSTK = B.RDRSTK 

, RDDEP = B.RDDEP , RDSYSD = B.RDSYSD , RDSYST = B.RDSYST 

, RD#HRS = B.RD#HRS , RDKIT = B.RDKIT , RDRNT$ = B.RDRNT$ 

, RDDW$ = B.RDDW$ , RDAMT$ = B.RDAMT$ , RDRTND = B.RDRTND 

, RDRTNT = B.RDRTNT , RDRDYS = B.RDRDYS , RDRHRS = B.RDRHRS 

, RDEMPC = B.RDEMPC , RDSYSY = B.RDSYSY , RDSYSM = B.RDSYSM 

, RDSYSA = B.RDSYSA , RDRLOC = B.RDRLOC , RDEXM$ = B.RDEXM$ 

, RDCRM# = B.RDCRM# , RDCMS# = B.RDCMS# , RDEXDT = B.RDEXDT 

, RDEXTM = B.RDEXTM , RDKIT# = B.RDKIT# , RDRATU = B.RDRATU 

, RDRTNW = B.RDRTNW , RDHRLR = B.RDHRLR , RDMNLR = B.RDMNLR 

, RDDYLR = B.RDDYLR , RDWKLR = B.RDWKLR , RDMOLR = B.RDMOLR 

, RD#CYB = B.RD#CYB , RDLBDF = B.RDLBDF , RDLBDT = B.RDLBDT 

, RD$TOB = B.RD$TOB , RD$BLD = B.RD$BLD , RDSYDO = B.RDSYDO 

, RDSYTO = B.RDSYTO , RDSHFD = B.RDSHFD , RDDPR$ = B.RDDPR$ 

, RDPONO = B.RDPONO , RDPOSQ = B.RDPOSQ , RDAMTE = B.RDAMTE 

, RDCNT# = B.RDCNT# , RDDsrc=B.RDDSRC , RDWsrc=B.RDWSRC 

, RDMsrc=B.RDMSRC , RDCDYS = B.RDCDYS , RDCHRS = B.RDCHRS 

, RDCRSN = B.RDCRSN , RDIRNO = B.RDIRNO , RDIRSQ = B.RDIRSQ 

, RDTAXC = B.RDTAXC , RDTAMT = B.RDTAMT , RDDWT$ = B.RDDWT$ 

, RDRCAT = B.RDRCAT , RDRCLS = B.RDRCLS , RDMHC2 = B.RDMHC2 

, RDMHO2 = B.RDMHO2 , RDMHI2 = B.RDMHI2 , RDEXM2 = B.RDEXM2 

, RDSSMP = B.RDSSMP , RDDSMP = B.RDDSMP , RDTSMP = B.RDTSMP 

, RDSSHR = B.RDSSHR , RDDSHR = B.RDDSHR , RDTSHR = B.RDTSHR 

, RDSAT = B.RDSAT , RDSUN = B.RDSUN , RDPRMD = B.RDPRMD , RDMOD = B.RDMOD 

, RDPRWD = B.RDPRWD , RDWKD = B.RDWKD , RDDYD = B.RDDYD , RDCSUB = B.RDCSUB 

, RDUWRC = B.RDUWRC , RDSUSH = B.RDSUSH , RDPBLI = B.RDPBLI 

, ETL_INSRT_PRCS_RUN_ID = B.ETL_INSRT_PRCS_RUN_ID , ETL_SRC_XTC_INSRT_PRCS_RUN_ID = B.ETL_INSRT_PRCS_RUN_ID 

, ETL_UPDT_PRCS_RUN_ID = B.ETL_INSRT_PRCS_RUN_ID , ETL_SRC_XTC_UPDT_PRCS_RUN_ID = B.ETL_INSRT_PRCS_RUN_ID

    WHERE (((((((( A.RDCMP =  ((

    CASE

        WHEN (NOT (B.RDCMP IS NULL )) THEN (B.RDCMP ) 

ELSE ('##')

    END ))) 

AND (A.RDCON# =  ((

    CASE

        WHEN (NOT (B.RDCON# IS NULL )) THEN (B.RDCON# ) 

ELSE (-9999999 )

    END )))) 

AND (A.RDISEQ =  ((

    CASE

        WHEN (NOT (B.RDISEQ IS NULL )) THEN (B.RDISEQ ) 

ELSE (-9999999 )

    END )))) 

AND (A.RDTYPE =  ((

    CASE

        WHEN (NOT (B.RDTYPE IS NULL )) THEN (B.RDTYPE ) 

ELSE ('##')

    END )))) 

AND (A.RDSEQ# =  ((

    CASE

        WHEN (NOT (B.RDSEQ# IS NULL )) THEN (B.RDSEQ# ) 

ELSE (-9999999 )

    END )))) 

AND (A.RDRSEQ =  ((

    CASE

        WHEN (NOT (B.RDRSEQ IS NULL )) THEN (B.RDRSEQ ) 

ELSE (-9999999 )

    END )))) 

AND (A.SRC_CTLG_NM =  'AS4HRCCP')) 

AND (A.SRC_SCHM_NM =  'WSDATA'))

        AND  ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((A.RDLOC IS NULL ) 

        AND  (NOT (B.RDLOC IS NULL ))) 

OR ((NOT (A.RDLOC IS NULL )) 

AND (B.RDLOC IS NULL ))) 

        OR  (A.RDLOC <>  B.RDLOC )) 

OR ((((A.RDCATG IS NULL ) 

AND (NOT (B.RDCATG IS NULL ))) 

        OR  ((NOT (A.RDCATG IS NULL )) 

AND (B.RDCATG IS NULL ))) 

OR (A.RDCATG <>  B.RDCATG ))) 

        OR  ((((A.RDCLAS IS NULL ) 

AND (NOT (B.RDCLAS IS NULL ))) 

OR ((NOT (A.RDCLAS IS NULL )) 

AND (B.RDCLAS IS NULL ))) 

OR (A.RDCLAS <>  B.RDCLAS ))) 

OR ((((A.RDSUBC IS NULL ) 

AND (NOT (B.RDSUBC IS NULL ))) 

OR ((NOT (A.RDSUBC IS NULL )) 

AND (B.RDSUBC IS NULL ))) 

OR (A.RDSUBC <>  B.RDSUBC ))) 

OR ((((A.RDITEM IS NULL ) 

AND (NOT (B.RDITEM IS NULL ))) 

OR ((NOT (A.RDITEM IS NULL )) 

AND (B.RDITEM IS NULL ))) 

OR (A.RDITEM <>  B.RDITEM ))) 

OR ((((A.RDSTKC IS NULL ) 

AND (NOT (B.RDSTKC IS NULL ))) 

OR ((NOT (A.RDSTKC IS NULL )) 

AND (B.RDSTKC IS NULL ))) 

OR (A.RDSTKC <>  B.RDSTKC ))) 

OR ((((A.RDQTY IS NULL ) 

AND (NOT (B.RDQTY IS NULL ))) 

OR ((NOT (A.RDQTY IS NULL )) 

AND (B.RDQTY IS NULL ))) 

OR (A.RDQTY <>  B.RDQTY ))) 

OR ((((A.RDQTYR IS NULL ) 

AND (NOT (B.RDQTYR IS NULL ))) 

OR ((NOT (A.RDQTYR IS NULL )) 

AND (B.RDQTYR IS NULL ))) 

OR (A.RDQTYR <>  B.RDQTYR ))) 

OR ((((A.RDCUS# IS NULL ) 

AND (NOT (B.RDCUS# IS NULL ))) 

OR ((NOT (A.RDCUS# IS NULL )) 

AND (B.RDCUS# IS NULL ))) 

OR (A.RDCUS# <>  B.RDCUS# ))) 

OR ((((A.RDDLST IS NULL ) 

AND (NOT (B.RDDLST IS NULL ))) 

OR ((NOT (A.RDDLST IS NULL )) 

AND (B.RDDLST IS NULL ))) 

OR (A.RDDLST <>  B.RDDLST ))) 

OR ((((A.RDDL# IS NULL ) 

AND (NOT (B.RDDL# IS NULL ))) 

OR ((NOT (A.RDDL# IS NULL )) 

AND (B.RDDL# IS NULL ))) 

OR (A.RDDL# <>  B.RDDL# ))) 

OR ((((A.RDOVR IS NULL ) 

AND (NOT (B.RDOVR IS NULL ))) 

OR ((NOT (A.RDOVR IS NULL )) 

AND (B.RDOVR IS NULL ))) 

OR (A.RDOVR <>  B.RDOVR ))) 

OR ((((A.RDMHCD IS NULL ) 

AND (NOT (B.RDMHCD IS NULL ))) 

OR ((NOT (A.RDMHCD IS NULL )) 

AND (B.RDMHCD IS NULL ))) 

OR (A.RDMHCD <>  B.RDMHCD ))) 

OR ((((A.RDMHO IS NULL ) 

AND (NOT (B.RDMHO IS NULL ))) 

OR ((NOT (A.RDMHO IS NULL )) 

AND (B.RDMHO IS NULL ))) 

OR (A.RDMHO <>  B.RDMHO ))) 

OR ((((A.RDMHI IS NULL ) 

AND (NOT (B.RDMHI IS NULL ))) 

OR ((NOT (A.RDMHI IS NULL )) 

AND (B.RDMHI IS NULL ))) 

OR (A.RDMHI <>  B.RDMHI ))) 

OR ((((A.RDMICG IS NULL ) 

AND (NOT (B.RDMICG IS NULL ))) 

OR ((NOT (A.RDMICG IS NULL )) 

AND (B.RDMICG IS NULL ))) 

OR (A.RDMICG <>  B.RDMICG ))) 

OR ((((A.RDHRRT IS NULL ) 

AND (NOT (B.RDHRRT IS NULL ))) 

OR ((NOT (A.RDHRRT IS NULL )) 

AND (B.RDHRRT IS NULL ))) 

OR (A.RDHRRT <>  B.RDHRRT ))) 

OR ((((A.RDMNRT IS NULL ) 

AND (NOT (B.RDMNRT IS NULL ))) 

OR ((NOT (A.RDMNRT IS NULL )) 

AND (B.RDMNRT IS NULL ))) 

OR (A.RDMNRT <>  B.RDMNRT ))) 

OR ((((A.RDDYRT IS NULL ) 

AND (NOT (B.RDDYRT IS NULL ))) 

OR ((NOT (A.RDDYRT IS NULL )) 

AND (B.RDDYRT IS NULL ))) 

OR (A.RDDYRT <>  B.RDDYRT ))) 

OR ((((A.RDWKRT IS NULL ) 

AND (NOT (B.RDWKRT IS NULL ))) 

OR ((NOT (A.RDWKRT IS NULL )) 

AND (B.RDWKRT IS NULL ))) 

OR (A.RDWKRT <>  B.RDWKRT ))) 

OR ((((A.RDMORT IS NULL ) 

AND (NOT (B.RDMORT IS NULL ))) 

OR ((NOT (A.RDMORT IS NULL )) 

AND (B.RDMORT IS NULL ))) 

OR (A.RDMORT <>  B.RDMORT ))) 

OR ((((A.RDDWP IS NULL ) 

AND (NOT (B.RDDWP IS NULL ))) 

OR ((NOT (A.RDDWP IS NULL )) 

AND (B.RDDWP IS NULL ))) 

OR (A.RDDWP <>  B.RDDWP ))) 

OR ((((A.RDDWD IS NULL ) 

AND (NOT (B.RDDWD IS NULL ))) 

OR ((NOT (A.RDDWD IS NULL )) 

AND (B.RDDWD IS NULL ))) 

OR (A.RDDWD <>  B.RDDWD ))) 

OR ((((A.RDDWW IS NULL ) 

AND (NOT (B.RDDWW IS NULL ))) 

OR ((NOT (A.RDDWW IS NULL )) 

AND (B.RDDWW IS NULL ))) 

OR (A.RDDWW <>  B.RDDWW ))) 

OR ((((A.RDDWM IS NULL ) 

AND (NOT (B.RDDWM IS NULL ))) 

OR ((NOT (A.RDDWM IS NULL )) 

AND (B.RDDWM IS NULL ))) 

OR (A.RDDWM <>  B.RDDWM ))) 

OR ((((A.RDPRCE IS NULL ) 

AND (NOT (B.RDPRCE IS NULL ))) 

OR ((NOT (A.RDPRCE IS NULL )) 

AND (B.RDPRCE IS NULL ))) 

OR (A.RDPRCE <>  B.RDPRCE ))) 

OR ((((A.RDUNIT IS NULL ) 

AND (NOT (B.RDUNIT IS NULL ))) 

OR ((NOT (A.RDUNIT IS NULL )) 

AND (B.RDUNIT IS NULL ))) 

OR (A.RDUNIT <>  B.RDUNIT ))) 

OR ((((A.RD#RTN IS NULL ) 

AND (NOT (B.RD#RTN IS NULL ))) 

OR ((NOT (A.RD#RTN IS NULL )) 

AND (B.RD#RTN IS NULL ))) 

OR (A.RD#RTN <>  B.RD#RTN ))) 

OR ((((A.RDDATO IS NULL ) 

AND (NOT (B.RDDATO IS NULL ))) 

OR ((NOT (A.RDDATO IS NULL )) 

AND (B.RDDATO IS NULL ))) 

OR (A.RDDATO <>  B.RDDATO ))) 

OR ((((A.RDTIMO IS NULL ) 

AND (NOT (B.RDTIMO IS NULL ))) 

OR ((NOT (A.RDTIMO IS NULL )) 

AND (B.RDTIMO IS NULL ))) 

OR (A.RDTIMO <>  B.RDTIMO ))) 

OR ((((A.RDDATI IS NULL ) 

AND (NOT (B.RDDATI IS NULL ))) 

OR ((NOT (A.RDDATI IS NULL )) 

AND (B.RDDATI IS NULL ))) 

OR (A.RDDATI <>  B.RDDATI ))) 

OR ((((A.RDTIMI IS NULL ) 

AND (NOT (B.RDTIMI IS NULL ))) 

OR ((NOT (A.RDTIMI IS NULL )) 

AND (B.RDTIMI IS NULL ))) 

OR (A.RDTIMI <>  B.RDTIMI ))) 

OR ((((A.RDSTTS IS NULL ) 

AND (NOT (B.RDSTTS IS NULL ))) 

OR ((NOT (A.RDSTTS IS NULL )) 

AND (B.RDSTTS IS NULL ))) 

OR (A.RDSTTS <>  B.RDSTTS ))) 

OR ((((A.RDDSCP IS NULL ) 

AND (NOT (B.RDDSCP IS NULL ))) 

OR ((NOT (A.RDDSCP IS NULL )) 

AND (B.RDDSCP IS NULL ))) 

OR (A.RDDSCP <>  B.RDDSCP ))) 

OR ((((A.RDDSC$ IS NULL ) 

AND (NOT (B.RDDSC$ IS NULL ))) 

OR ((NOT (A.RDDSC$ IS NULL )) 

AND (B.RDDSC$ IS NULL ))) 

OR (A.RDDSC$ <>  B.RDDSC$ ))) 

OR ((((A.RDCOST IS NULL ) 

AND (NOT (B.RDCOST IS NULL ))) 

OR ((NOT (A.RDCOST IS NULL )) 

AND (B.RDCOST IS NULL ))) 

OR (A.RDCOST <>  B.RDCOST ))) 

OR ((((A.RDCOM IS NULL ) 

AND (NOT (B.RDCOM IS NULL ))) 

OR ((NOT (A.RDCOM IS NULL )) 

AND (B.RDCOM IS NULL ))) 

OR (A.RDCOM <>  B.RDCOM ))) 

OR ((((A.RDTAX IS NULL ) 

AND (NOT (B.RDTAX IS NULL ))) 

OR ((NOT (A.RDTAX IS NULL )) 

AND (B.RDTAX IS NULL ))) 

OR (A.RDTAX <>  B.RDTAX ))) 

OR ((((A.RDRSNC IS NULL ) 

AND (NOT (B.RDRSNC IS NULL ))) 

OR ((NOT (A.RDRSNC IS NULL )) 

AND (B.RDRSNC IS NULL ))) 

OR (A.RDRSNC <>  B.RDRSNC ))) 

OR ((((A.RDRSTK IS NULL ) 

AND (NOT (B.RDRSTK IS NULL ))) 

OR ((NOT (A.RDRSTK IS NULL )) 

AND (B.RDRSTK IS NULL ))) 

OR (A.RDRSTK <>  B.RDRSTK ))) 

OR ((((A.RDDEP IS NULL ) 

AND (NOT (B.RDDEP IS NULL ))) 

OR ((NOT (A.RDDEP IS NULL )) 

AND (B.RDDEP IS NULL ))) 

OR (A.RDDEP <>  B.RDDEP ))) 

OR ((((A.RDSYSD IS NULL ) 

AND (NOT (B.RDSYSD IS NULL ))) 

OR ((NOT (A.RDSYSD IS NULL )) 

AND (B.RDSYSD IS NULL ))) 

OR (A.RDSYSD <>  B.RDSYSD ))) 

OR ((((A.RDSYST IS NULL ) 

AND (NOT (B.RDSYST IS NULL ))) 

OR ((NOT (A.RDSYST IS NULL )) 

AND (B.RDSYST IS NULL ))) 

OR (A.RDSYST <>  B.RDSYST ))) 

OR ((((A.RD#HRS IS NULL ) 

AND (NOT (B.RD#HRS IS NULL ))) 

OR ((NOT (A.RD#HRS IS NULL )) 

AND (B.RD#HRS IS NULL ))) 

OR (A.RD#HRS <>  B.RD#HRS ))) 

OR ((((A.RDKIT IS NULL ) 

AND (NOT (B.RDKIT IS NULL ))) 

OR ((NOT (A.RDKIT IS NULL )) 

AND (B.RDKIT IS NULL ))) 

OR (A.RDKIT <>  B.RDKIT ))) 

OR ((((A.RDRNT$ IS NULL ) 

AND (NOT (B.RDRNT$ IS NULL ))) 

OR ((NOT (A.RDRNT$ IS NULL )) 

AND (B.RDRNT$ IS NULL ))) 

OR (A.RDRNT$ <>  B.RDRNT$ ))) 

OR ((((A.RDDW$ IS NULL ) 

AND (NOT (B.RDDW$ IS NULL ))) 

OR ((NOT (A.RDDW$ IS NULL )) 

AND (B.RDDW$ IS NULL ))) 

OR (A.RDDW$ <>  B.RDDW$ ))) 

OR ((((A.RDAMT$ IS NULL ) 

AND (NOT (B.RDAMT$ IS NULL ))) 

OR ((NOT (A.RDAMT$ IS NULL )) 

AND (B.RDAMT$ IS NULL ))) 

OR (A.RDAMT$ <>  B.RDAMT$ ))) 

OR ((((A.RDRTND IS NULL ) 

AND (NOT (B.RDRTND IS NULL ))) 

OR ((NOT (A.RDRTND IS NULL )) 

AND (B.RDRTND IS NULL ))) 

OR (A.RDRTND <>  B.RDRTND ))) 

OR ((((A.RDRTNT IS NULL ) 

AND (NOT (B.RDRTNT IS NULL ))) 

OR ((NOT (A.RDRTNT IS NULL )) 

AND (B.RDRTNT IS NULL ))) 

OR (A.RDRTNT <>  B.RDRTNT ))) 

OR ((((A.RDRDYS IS NULL ) 

AND (NOT (B.RDRDYS IS NULL ))) 

OR ((NOT (A.RDRDYS IS NULL )) 

AND (B.RDRDYS IS NULL ))) 

OR (A.RDRDYS <>  B.RDRDYS ))) 

OR ((((A.RDRHRS IS NULL ) 

AND (NOT (B.RDRHRS IS NULL ))) 

OR ((NOT (A.RDRHRS IS NULL )) 

AND (B.RDRHRS IS NULL ))) 

OR (A.RDRHRS <>  B.RDRHRS ))) 

OR ((((A.RDEMPC IS NULL ) 

AND (NOT (B.RDEMPC IS NULL ))) 

OR ((NOT (A.RDEMPC IS NULL )) 

AND (B.RDEMPC IS NULL ))) 

OR (A.RDEMPC <>  B.RDEMPC ))) 

OR ((((A.RDSYSY IS NULL ) 

AND (NOT (B.RDSYSY IS NULL ))) 

OR ((NOT (A.RDSYSY IS NULL )) 

AND (B.RDSYSY IS NULL ))) 

OR (A.RDSYSY <>  B.RDSYSY ))) 

OR ((((A.RDSYSM IS NULL ) 

AND (NOT (B.RDSYSM IS NULL ))) 

OR ((NOT (A.RDSYSM IS NULL )) 

AND (B.RDSYSM IS NULL ))) 

OR (A.RDSYSM <>  B.RDSYSM ))) 

OR ((((A.RDSYSA IS NULL ) 

AND (NOT (B.RDSYSA IS NULL ))) 

OR ((NOT (A.RDSYSA IS NULL )) 

AND (B.RDSYSA IS NULL ))) 

OR (A.RDSYSA <>  B.RDSYSA ))) 

OR ((((A.RDRLOC IS NULL ) 

AND (NOT (B.RDRLOC IS NULL ))) 

OR ((NOT (A.RDRLOC IS NULL )) 

AND (B.RDRLOC IS NULL ))) 

OR (A.RDRLOC <>  B.RDRLOC ))) 

OR ((((A.RDEXM$ IS NULL ) 

AND (NOT (B.RDEXM$ IS NULL ))) 

OR ((NOT (A.RDEXM$ IS NULL )) 

AND (B.RDEXM$ IS NULL ))) 

OR (A.RDEXM$ <>  B.RDEXM$ ))) 

OR ((((A.RDCRM# IS NULL ) 

AND (NOT (B.RDCRM# IS NULL ))) 

OR ((NOT (A.RDCRM# IS NULL )) 

AND (B.RDCRM# IS NULL ))) 

OR (A.RDCRM# <>  B.RDCRM# ))) 

OR ((((A.RDCMS# IS NULL ) 

AND (NOT (B.RDCMS# IS NULL ))) 

OR ((NOT (A.RDCMS# IS NULL )) 

AND (B.RDCMS# IS NULL ))) 

OR (A.RDCMS# <>  B.RDCMS# ))) 

OR ((((A.RDEXDT IS NULL ) 

AND (NOT (B.RDEXDT IS NULL ))) 

OR ((NOT (A.RDEXDT IS NULL )) 

AND (B.RDEXDT IS NULL ))) 

OR (A.RDEXDT <>  B.RDEXDT ))) 

OR ((((A.RDEXTM IS NULL ) 

AND (NOT (B.RDEXTM IS NULL ))) 

OR ((NOT (A.RDEXTM IS NULL )) 

AND (B.RDEXTM IS NULL ))) 

OR (A.RDEXTM <>  B.RDEXTM ))) 

OR ((((A.RDKIT# IS NULL ) 

AND (NOT (B.RDKIT# IS NULL ))) 

OR ((NOT (A.RDKIT# IS NULL )) 

AND (B.RDKIT# IS NULL ))) 

OR (A.RDKIT# <>  B.RDKIT# ))) 

OR ((((A.RDRATU IS NULL ) 

AND (NOT (B.RDRATU IS NULL ))) 

OR ((NOT (A.RDRATU IS NULL )) 

AND (B.RDRATU IS NULL ))) 

OR (A.RDRATU <>  B.RDRATU ))) 

OR ((((A.RDRTNW IS NULL ) 

AND (NOT (B.RDRTNW IS NULL ))) 

OR ((NOT (A.RDRTNW IS NULL )) 

AND (B.RDRTNW IS NULL ))) 

OR (A.RDRTNW <>  B.RDRTNW ))) 

OR ((((A.RDHRLR IS NULL ) 

AND (NOT (B.RDHRLR IS NULL ))) 

OR ((NOT (A.RDHRLR IS NULL )) 

AND (B.RDHRLR IS NULL ))) 

OR (A.RDHRLR <>  B.RDHRLR ))) 

OR ((((A.RDMNLR IS NULL ) 

AND (NOT (B.RDMNLR IS NULL ))) 

OR ((NOT (A.RDMNLR IS NULL )) 

AND (B.RDMNLR IS NULL ))) 

OR (A.RDMNLR <>  B.RDMNLR ))) 

OR ((((A.RDDYLR IS NULL ) 

AND (NOT (B.RDDYLR IS NULL ))) 

OR ((NOT (A.RDDYLR IS NULL )) 

AND (B.RDDYLR IS NULL ))) 

OR (A.RDDYLR <>  B.RDDYLR ))) 

OR ((((A.RDWKLR IS NULL ) 

AND (NOT (B.RDWKLR IS NULL ))) 

OR ((NOT (A.RDWKLR IS NULL )) 

AND (B.RDWKLR IS NULL ))) 

OR (A.RDWKLR <>  B.RDWKLR ))) 

OR ((((A.RDMOLR IS NULL ) 

AND (NOT (B.RDMOLR IS NULL ))) 

OR ((NOT (A.RDMOLR IS NULL )) 

AND (B.RDMOLR IS NULL ))) 

OR (A.RDMOLR <>  B.RDMOLR ))) 

OR ((((A.RD#CYB IS NULL ) 

AND (NOT (B.RD#CYB IS NULL ))) 

OR ((NOT (A.RD#CYB IS NULL )) 

AND (B.RD#CYB IS NULL ))) 

OR (A.RD#CYB <>  B.RD#CYB ))) 

OR ((((A.RDLBDF IS NULL ) 

AND (NOT (B.RDLBDF IS NULL ))) 

OR ((NOT (A.RDLBDF IS NULL )) 

AND (B.RDLBDF IS NULL ))) 

OR (A.RDLBDF <>  B.RDLBDF ))) 

OR ((((A.RDLBDT IS NULL ) 

AND (NOT (B.RDLBDT IS NULL ))) 

OR ((NOT (A.RDLBDT IS NULL )) 

AND (B.RDLBDT IS NULL ))) 

OR (A.RDLBDT <>  B.RDLBDT ))) 

OR ((((A.RD$TOB IS NULL ) 

AND (NOT (B.RD$TOB IS NULL ))) 

OR ((NOT (A.RD$TOB IS NULL )) 

AND (B.RD$TOB IS NULL ))) 

OR (A.RD$TOB <>  B.RD$TOB ))) 

OR ((((A.RD$BLD IS NULL ) 

AND (NOT (B.RD$BLD IS NULL ))) 

OR ((NOT (A.RD$BLD IS NULL )) 

AND (B.RD$BLD IS NULL ))) 

OR (A.RD$BLD <>  B.RD$BLD ))) 

OR ((((A.RDSYDO IS NULL ) 

AND (NOT (B.RDSYDO IS NULL ))) 

OR ((NOT (A.RDSYDO IS NULL )) 

AND (B.RDSYDO IS NULL ))) 

OR (A.RDSYDO <>  B.RDSYDO ))) 

OR ((((A.RDSYTO IS NULL ) 

AND (NOT (B.RDSYTO IS NULL ))) 

OR ((NOT (A.RDSYTO IS NULL )) 

AND (B.RDSYTO IS NULL ))) 

OR (A.RDSYTO <>  B.RDSYTO ))) 

OR ((((A.RDSHFD IS NULL ) 

AND (NOT (B.RDSHFD IS NULL ))) 

OR ((NOT (A.RDSHFD IS NULL )) 

AND (B.RDSHFD IS NULL ))) 

OR (A.RDSHFD <>  B.RDSHFD ))) 

OR ((((A.RDDPR$ IS NULL ) 

AND (NOT (B.RDDPR$ IS NULL ))) 

OR ((NOT (A.RDDPR$ IS NULL )) 

AND (B.RDDPR$ IS NULL ))) 

OR (A.RDDPR$ <>  B.RDDPR$ ))) 

OR ((((A.RDPONO IS NULL ) 

AND (NOT (B.RDPONO IS NULL ))) 

OR ((NOT (A.RDPONO IS NULL )) 

AND (B.RDPONO IS NULL ))) 

OR (A.RDPONO <>  B.RDPONO ))) 

OR ((((A.RDPOSQ IS NULL ) 

AND (NOT (B.RDPOSQ IS NULL ))) 

OR ((NOT (A.RDPOSQ IS NULL )) 

AND (B.RDPOSQ IS NULL ))) 

OR (A.RDPOSQ <>  B.RDPOSQ ))) 

OR ((((A.RDAMTE IS NULL ) 

AND (NOT (B.RDAMTE IS NULL ))) 

OR ((NOT (A.RDAMTE IS NULL )) 

AND (B.RDAMTE IS NULL ))) 

OR (A.RDAMTE <>  B.RDAMTE ))) 

OR ((((A.RDCNT# IS NULL ) 

AND (NOT (B.RDCNT# IS NULL ))) 

OR ((NOT (A.RDCNT# IS NULL )) 

AND (B.RDCNT# IS NULL ))) 

OR (A.RDCNT# <>  B.RDCNT# ))) 

OR ((((A.RDDSRC IS NULL ) 

AND (NOT (B.RDDSRC IS NULL ))) 

OR ((NOT (A.RDDSRC IS NULL )) 

AND (B.RDDSRC IS NULL ))) 

OR (A.RDDSRC <>  B.RDDSRC ))) 

OR ((((A.RDWSRC IS NULL ) 

AND (NOT (B.RDWSRC IS NULL ))) 

OR ((NOT (A.RDWSRC IS NULL )) 

AND (B.RDWSRC IS NULL ))) 

OR (A.RDWSRC <>  B.RDWSRC ))) 

OR ((((A.RDMSRC IS NULL ) 

AND (NOT (B.RDMSRC IS NULL ))) 

OR ((NOT (A.RDMSRC IS NULL )) 

AND (B.RDMSRC IS NULL ))) 

OR (A.RDMSRC <>  B.RDMSRC ))) 

OR ((((A.RDCDYS IS NULL ) 

AND (NOT (B.RDCDYS IS NULL ))) 

OR ((NOT (A.RDCDYS IS NULL )) 

AND (B.RDCDYS IS NULL ))) 

OR (A.RDCDYS <>  B.RDCDYS ))) 

OR ((((A.RDCHRS IS NULL ) 

AND (NOT (B.RDCHRS IS NULL ))) 

OR ((NOT (A.RDCHRS IS NULL )) 

AND (B.RDCHRS IS NULL ))) 

OR (A.RDCHRS <>  B.RDCHRS ))) 

OR ((((A.RDCRSN IS NULL ) 

AND (NOT (B.RDCRSN IS NULL ))) 

OR ((NOT (A.RDCRSN IS NULL )) 

AND (B.RDCRSN IS NULL ))) 

OR (A.RDCRSN <>  B.RDCRSN ))) 

OR ((((A.RDIRNO IS NULL ) 

AND (NOT (B.RDIRNO IS NULL ))) 

OR ((NOT (A.RDIRNO IS NULL )) 

AND (B.RDIRNO IS NULL ))) 

OR (A.RDIRNO <>  B.RDIRNO ))) 

OR ((((A.RDIRSQ IS NULL ) 

AND (NOT (B.RDIRSQ IS NULL ))) 

OR ((NOT (A.RDIRSQ IS NULL )) 

AND (B.RDIRSQ IS NULL ))) 

OR (A.RDIRSQ <>  B.RDIRSQ ))) 

OR ((((A.RDTAXC IS NULL ) 

AND (NOT (B.RDTAXC IS NULL ))) 

OR ((NOT (A.RDTAXC IS NULL )) 

AND (B.RDTAXC IS NULL ))) 

OR (A.RDTAXC <>  B.RDTAXC ))) 

OR ((((A.RDTAMT IS NULL ) 

AND (NOT (B.RDTAMT IS NULL ))) 

OR ((NOT (A.RDTAMT IS NULL )) 

AND (B.RDTAMT IS NULL ))) 

OR (A.RDTAMT <>  B.RDTAMT ))) 

OR ((((A.RDDWT$ IS NULL ) 

AND (NOT (B.RDDWT$ IS NULL ))) 

OR ((NOT (A.RDDWT$ IS NULL )) 

AND (B.RDDWT$ IS NULL ))) 

OR (A.RDDWT$ <>  B.RDDWT$ ))) 

OR ((((A.RDRCAT IS NULL ) 

AND (NOT (B.RDRCAT IS NULL ))) 

OR ((NOT (A.RDRCAT IS NULL )) 

AND (B.RDRCAT IS NULL ))) 

OR (A.RDRCAT <>  B.RDRCAT ))) 

OR ((((A.RDRCLS IS NULL ) 

AND (NOT (B.RDRCLS IS NULL ))) 

OR ((NOT (A.RDRCLS IS NULL )) 

AND (B.RDRCLS IS NULL ))) 

OR (A.RDRCLS <>  B.RDRCLS ))) 

OR ((((A.RDMHC2 IS NULL ) 

AND (NOT (B.RDMHC2 IS NULL ))) 

OR ((NOT (A.RDMHC2 IS NULL )) 

AND (B.RDMHC2 IS NULL ))) 

OR (A.RDMHC2 <>  B.RDMHC2 ))) 

OR ((((A.RDMHO2 IS NULL ) 

AND (NOT (B.RDMHO2 IS NULL ))) 

OR ((NOT (A.RDMHO2 IS NULL )) 

AND (B.RDMHO2 IS NULL ))) 

OR (A.RDMHO2 <>  B.RDMHO2 ))) 

OR ((((A.RDMHI2 IS NULL ) 

AND (NOT (B.RDMHI2 IS NULL ))) 

OR ((NOT (A.RDMHI2 IS NULL )) 

AND (B.RDMHI2 IS NULL ))) 

OR (A.RDMHI2 <>  B.RDMHI2 ))) 

OR ((((A.RDEXM2 IS NULL ) 

AND (NOT (B.RDEXM2 IS NULL ))) 

OR ((NOT (A.RDEXM2 IS NULL )) 

AND (B.RDEXM2 IS NULL ))) 

OR (A.RDEXM2 <>  B.RDEXM2 ))) 

OR ((((A.RDSSMP IS NULL ) 

AND (NOT (B.RDSSMP IS NULL ))) 

OR ((NOT (A.RDSSMP IS NULL )) 

AND (B.RDSSMP IS NULL ))) 

OR (A.RDSSMP <>  B.RDSSMP ))) 

OR ((((A.RDDSMP IS NULL ) 

AND (NOT (B.RDDSMP IS NULL ))) 

OR ((NOT (A.RDDSMP IS NULL )) 

AND (B.RDDSMP IS NULL ))) 

OR (A.RDDSMP <>  B.RDDSMP ))) 

OR ((((A.RDTSMP IS NULL ) 

AND (NOT (B.RDTSMP IS NULL ))) 

OR ((NOT (A.RDTSMP IS NULL )) 

AND (B.RDTSMP IS NULL ))) 

OR (A.RDTSMP <>  B.RDTSMP ))) 

OR ((((A.RDSSHR IS NULL ) 

AND (NOT (B.RDSSHR IS NULL ))) 

OR ((NOT (A.RDSSHR IS NULL )) 

AND (B.RDSSHR IS NULL ))) 

OR (A.RDSSHR <>  B.RDSSHR ))) 

OR ((((A.RDDSHR IS NULL ) 

AND (NOT (B.RDDSHR IS NULL ))) 

OR ((NOT (A.RDDSHR IS NULL )) 

AND (B.RDDSHR IS NULL ))) 

OR (A.RDDSHR <>  B.RDDSHR ))) 

OR ((((A.RDTSHR IS NULL ) 

AND (NOT (B.RDTSHR IS NULL ))) 

OR ((NOT (A.RDTSHR IS NULL )) 

AND (B.RDTSHR IS NULL ))) 

OR (A.RDTSHR <>  B.RDTSHR ))) 

OR ((((A.RDSAT IS NULL ) 

AND (NOT (B.RDSAT IS NULL ))) 

OR ((NOT (A.RDSAT IS NULL )) 

AND (B.RDSAT IS NULL ))) 

OR (A.RDSAT <>  B.RDSAT ))) 

OR ((((A.RDSUN IS NULL ) 

AND (NOT (B.RDSUN IS NULL ))) 

OR ((NOT (A.RDSUN IS NULL )) 

AND (B.RDSUN IS NULL ))) 

OR (A.RDSUN <>  B.RDSUN ))) 

OR ((((A.RDPRMD IS NULL ) 

AND (NOT (B.RDPRMD IS NULL ))) 

OR ((NOT (A.RDPRMD IS NULL )) 

AND (B.RDPRMD IS NULL ))) 

OR (A.RDPRMD <>  B.RDPRMD ))) 

OR ((((A.RDMOD IS NULL ) 

AND (NOT (B.RDMOD IS NULL ))) 

OR ((NOT (A.RDMOD IS NULL )) 

AND (B.RDMOD IS NULL ))) 

OR (A.RDMOD <>  B.RDMOD ))) 

OR ((((A.RDPRWD IS NULL ) 

AND (NOT (B.RDPRWD IS NULL ))) 

OR ((NOT (A.RDPRWD IS NULL )) 

AND (B.RDPRWD IS NULL ))) 

OR (A.RDPRWD <>  B.RDPRWD ))) 

OR ((((A.RDWKD IS NULL ) 

AND (NOT (B.RDWKD IS NULL ))) 

OR ((NOT (A.RDWKD IS NULL )) 

AND (B.RDWKD IS NULL ))) 

OR (A.RDWKD <>  B.RDWKD ))) 

OR ((((A.RDDYD IS NULL ) 

AND (NOT (B.RDDYD IS NULL ))) 

OR ((NOT (A.RDDYD IS NULL )) 

AND (B.RDDYD IS NULL ))) 

OR (A.RDDYD <>  B.RDDYD ))) 

OR ((((A.RDCSUB IS NULL ) 

AND (NOT (B.RDCSUB IS NULL ))) 

OR ((NOT (A.RDCSUB IS NULL )) 

AND (B.RDCSUB IS NULL ))) 

OR (A.RDCSUB <>  B.RDCSUB ))) 

OR ((((A.RDUWRC IS NULL ) 

AND (NOT (B.RDUWRC IS NULL ))) 

OR ((NOT (A.RDUWRC IS NULL )) 

AND (B.RDUWRC IS NULL ))) 

OR (A.RDUWRC <>  B.RDUWRC ))) 

OR ((((A.RDSUSH IS NULL ) 

AND (NOT (B.RDSUSH IS NULL ))) 

OR ((NOT (A.RDSUSH IS NULL )) 

AND (B.RDSUSH IS NULL ))) 

OR (A.RDSUSH <>  B.RDSUSH ))) 

OR ((((A.RDPBLI IS NULL ) 

AND (NOT (B.RDPBLI IS NULL ))) 

OR ((NOT (A.RDPBLI IS NULL )) 

AND (B.RDPBLI IS NULL ))) 

OR (A.RDPBLI <>  B.RDPBLI )));
1 REPLY
Teradata Employee

Re: Update Query Optimization

Try using UPSERT instead of UPDATE and COALESCE or DEFAULT (table level) instead of CASE.