Skip to Content
0
Jul 11, 2019 at 12:32 PM

Tuning SQL PLAN on DB2

240 Views Last edit Jul 11, 2019 at 07:56 AM 3 rev

Hello Experts,

I have a problem about Execution Plan of a SQL with binding variables bellows:

SQL1: Run very fast with plan on attached file

SELECT count(*)

FROM JHMATCH m
INNER JOIN VHBORDER bo
ON m.BORDERID = bo.ORDERID
INNER JOIN VCRPTTRADINGACCVN ta
ON bo.CLIENTID = ta.CLIENTID
AND bo.TRADINGACCSEQ = ta.TRADINGACCSEQ
and m.VALUEDATE >= '2019-06-03'
AND m.VALUEDATE <= '2019-06-30'

SQL2: Run very slow with plan on attached file

SELECT count(*)

FROM JHMATCH m
INNER JOIN VHBORDER bo
ON m.BORDERID = bo.ORDERID
INNER JOIN VCRPTTRADINGACCVN ta
ON bo.CLIENTID = ta.CLIENTID
AND bo.TRADINGACCSEQ = ta.TRADINGACCSEQ
and m.VALUEDATE >= '2019-06-02'
AND m.VALUEDATE <= '2019-06-30'

I executed the Runstats to gather statistics on tables JHMATCH, THBORDER and ran the SQL1, 2 againt but got the same problem. Please help me to tuning SQL2.

Many thanks,

Bgs, Vinhpv.

Attachments

sql1-plan.jpg (460.3 kB)
sql2-plan.jpg (455.1 kB)