sqltrace x prepare statements (4GL)
Posted in 2011
Hi, IFX 11.50 FC8 AIX 6.1 + 4GL 7.32 (with CSDK 3.50 FC8) I have a 4GL program, executing a simple foreach over a table with 1.5mi records code 1) If this foreach running as dummy, without any code inside , take 1 minute to run: declare xyz cursor select ...from xyz foreach xyz end foreach code 2) When included 2 distincts sqls into this foreach, the time go up 40min declare xyz cursor select ...from xyz foreach xyz select....into v_onono .... from abc.... select....into v_onono ....from abc.... end foreach code 3) When changed the code to declare a cursor before the foreach, the time go down 10min declare abc1cursor select....into v_onono ....from abc declare abc2 cursor select....into v_onono ....from abc declare xyz cursor select ... from xyz foreach xyz foreach abc1.... foreach abc2... end foreach This is obvious because the code 3 don't prepare 1.5mi times each SQL. When I capture the session of code 2 and code 3 with SQLTRACE I don't get the time of the prepare ... the Run time of execution of each SQL always is 0.0001 or 0.0000 for both situations The only differ I get is the amount of SQLs per second , what the code 3 is 4 times faster. The database have SQL Statement cache active.. First doubt. is there a way or trick to discovery when a SQL is prepared inumerous times repeatable , since the SQLTRACE don't show me any differ into their numbers... this looking at database side. Second doubt, can we consider this a bug or a new resource for SQLTRACE? I look for this like a bug and new resource, bug because they appear not compute the time of the optimizer prepare or use the SSC.... and this time , as exemplified, can be very very very considerable. This behave of SQLTRACE mask the problem at the DBA point of view. And I consider like new resource because a new field into SQLTRACE showing if the SQL was prepared/optimize that time what is executed will help a lot to identify SQLs being re-prepared unnecessarily. Regards Cesar