Archives of the TeradataForum
Message Posted: Wed, 18 Jun 2014 @ 22:14:52 GMT
Subj: | | Re: SQL with product join |
|
From: | | Curley, David |
Depending on your underlying data, it's easy to imagine that query returning a high percentage of rows given all those ORs. That might make a
product join a reasonable choice.
If you re-write it using and/not, do you get better performance? Something like this, assuming I have my or/and/equals/not equals/not logic
right:
(
VWDB.TAB1.ID_TYPE_CD = 1
AND not
( -- rows where all these are the case are the only ones to exclude.
VWDB.View1.PRIM_ID_IND <> 'N'
and
VWDB_View1.STAT_CD = 1
and
VWDB.View2.PRD_STATUS_CD = 6
and
VWDB.View2.DW_VER_END_DT = {d '9999-12-31'}
and
VWDB_VWS.View2.ACCT_TYPE_CD = 250
and
VWDB.View2.TAX_PRD_END_DT = {d '9999-12-31'}
)
)
Then maybe collect stats on (PRIM_ID_IND, STAT_CD ) and (PRD_STATUS_CD, DW_VER_END_DT , ACCT_TYPE_CD, TAX_PRD_END_DT) and see if that
helps.
Dave
|