Performance Issue -Run Time
Posted in 2005
<html><div style='background-color:'><DIV class=RTE>Hi Everyone,</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>Method# 1,</DIV> <DIV class=RTE>I have one 'prepare' statement set up:</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>'select * from tbl_1 where var1 = ? '</DIV> <DIV class=RTE>prepare ...</DIV> <DIV class=RTE>declare v_curs</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>inside a code:</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>open v_curs using g_rec.key_code</DIV> <DIV class=RTE>foreach ... into v_rec.*</DIV> <DIV class=RTE> <STRONG>if v_rec.number = g_rec.number then (variable that read from a data file)</STRONG></DIV> <DIV class=RTE><STRONG> skip record - goto a next record</STRONG></DIV> <DIV class=RTE><STRONG> end if</STRONG></DIV> <DIV class=RTE>end foreach</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>Method# 2,</DIV> <DIV class=RTE>If I prepare another statement, like below</DIV> <DIV class=RTE>'select count(*) from tbl_1 where var1 = ? and number = ? "</DIV> <DIV class=RTE>prepare ...</DIV> <DIV class=RTE>declare v2_curs ...</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>then inside foreach loop, instead of 'if-then' loop, use the 'v2_curs':</DIV> <DIV class=RTE>open v_curs</DIV> <DIV class=RTE>foreach ... into v_rec.*</DIV> <DIV class=RTE> <STRONG>open v2_curs using g_rec.key_code, g_rec.number</STRONG></DIV> <DIV class=RTE><STRONG> fetch v2_curs into v_cnt</STRONG></DIV> <DIV class=RTE> if v_cnt > 0 then</DIV> <DIV class=RTE> skip record</DIV> <DIV class=RTE> end if</DIV> <DIV class=RTE>end foreach</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>Question:</DIV> <DIV class=RTE>which method is faster in performance issue or anything related to? Since data file that this code read in is also huge file.</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>Thanks for your help</DIV> <DIV class=RTE>TD</DIV></div></html>