Tu Nguyen
asked on
The job run with error: SQL0437W Performance of this complex query may be sub-optimal. Reason code: "3". SQLSTATE=01602
Dear all,
I'm in problem when execute the job. The log show error: "SQL0437W Performance of this complex query may be sub-optimal. Reason code: "3". SQLSTATE=01602"
when run script of job. Please give me some advise for solving this. Thank you!
The psuedo script:
I'm in problem when execute the job. The log show error: "SQL0437W Performance of this complex query may be sub-optimal. Reason code: "3". SQLSTATE=01602"
when run script of job. Please give me some advise for solving this. Thank you!
The psuedo script:
update CVG set cvg_amt = select cvg_amt from
(select CASE WHEN CVG.CVG_AMT IS NULL THEN COM.CVG_AMT ELSE CVG.CVG_AMT END AS CVG_AMT
from cvg
left join
(select A.id, A.cvg_amt, CASE WHEN A.PROCESS_DT > B.PROCESS_DT THEN A.CVG_AMT ELSE B.CVG_AMT END AS CVG_AMT
from
( select A_first.id, A_first.cvg_amt, A_first.process_dt, A_first.gen_id from
(select id, cvg_amt, process_dt, gen_id, eff_dt from A where eff_dt < '2015-10-28') as A_first,
(select id, process_dt, max(gen_id ) as max_gen
from (select id, process_dt, gen_id from A as A1 where eff_dt < '2015-10-28') ,
(select A2.id, max(A2.process_dt) as max_dt from A as A2 where eff_dt < '2015-10-28' group by A2.id)
where eff_dt < '2015-10-28' and A2.id = A1.id and A2.max_dt=A1.process_dt group by A1.id, A1.process_dt) as A_second
where A_first.eff_dt<'2015-10-28'
and A_first.id=A_second.id
and A_first.process_dt = A_second.process_dt
and A_first.gen_id = A_second.gen_id
) A
left join
( select B_first.id, B_first.cvg_amt, B_first.process_dt, B_first.gen_id from
(select id, cvg_amt, process_dt, gen_id, eff_dt from B where eff_dt < '2015-10-28') as B_first,
(select id, process_dt, max(gen_id ) as max_gen
from (select id, process_dt, gen_id from B as B1 where eff_dt < '2015-10-28') ,
(select B2.id, max(B2.process_dt) as max_dt from B as B2 where eff_dt < '2015-10-28' group by B2.id)
where eff_dt < '2015-10-28' and B2.id = B1.id and B2.max_dt=B1.process_dt group by B1.id, B1.process_dt) as B_second
where B_first.eff_dt<'2015-10-28'
and B_first.id=B_second.id
and B_first.process_dt = B_second.process_dt
and B_first.gen_id = B_second.gen_id
) B on B.id = A.id
) COM ON COM.ID = CVG.ID)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your comment!
I can't have to authorize for configing again as the database.
So the solution "partitioning the table CVG" , I can't do.
I can only write the sql statement such that it's simpler.
The sql statement for update a field from table CVG as script I atached.
So can you suggest me the way I can enhance it more simpler?
Thanks for your guide!
Tu