Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10548

How to avoid data selection inside the loop?

$
0
0

Hello Experts,

 

I am working on one performance item and I have already applied some changes to the original version.

 

Now, If I compare my new program with old program, I have good improvement in performance. I am checking if I can do anything on statements that are top on the below list. I think 40% for Modify statement is acceptable after my research (Below run is updating around 20M records which is real time volume for this application).

 

perf.png

 

As we can see 34% of run time to going for one SELECT query on custom table. Take a look at below high level flow of my program to understand above select query.

 

1. Select data from ZABC

2. Select data from Variant Table (Var1, Var2, Var3 etc.., 12 in real time)

3. Loop Variant Table

4. Select data from X, Y, Z table for Var<n>.

5. Populate final internal table from ZABC, X, Y and Z table

6. Modify ZTABLE with Final Internal table data

7. End Loop on Variant Table

 

As described in the flow of the program, ZABC table data is common for all the variants and need not to fetch multiple times. Hence I am doing it only once in my program. Below is that select query:

 

select rrcty ryear rbukrs racct rcntr sum( amt1) as amt1  "Like I have 32 amount fields in original query           from zabc            into table i_zabc            where ryear in r_year    " Two records in ranges with I and EQ            and rvers = '001'            and rrcty in r_rrcty        "Three records in ranges with I and EQ            and rldnr = 'DT'            group by rrcty ryear rbukrs racct rcntr            order by rrcty ryear rbukrs racct rcntr.

ZABC table is again having huge volume of data and we are fetching millions of records with above query. That is primary reason to take long time. May be that is okay as I am already using Indexes of this table. But, I am not comfortable with it as it can reach max. memory point and through run time error. Fetch Cursor is one reliable option that I can see here, but with that, I should move ZABC selection inside the variant loop which can cause fetching ZABC data 12 times (Let me know If I am missing anything here).


Now, third statement in my trace results, with 10% of overall time is this:

 

loop at i_abc assigning <fs_abc>. 

... 

loop at i_table assigning <fs_table> where low <= <fs_abc>-racct and high >= <fs_abc>-racct. 

... 

endloop. 

...

endloop. 

6 million executions with this complex WHERE condition is causing this statement to get 3rd position in trace results. I tried below two options which are, I think, taking even more time - (I am still monitoring these options)

1) Removed WHERE condition on LOW, HIGH and applied filter inside the loop.

2) Removed WHERE condition on HIGH only and applied filter inside the loop.

 

Any suggestions on how to proceed with ZABC selection and I_TABLE loop.

 

Let me know if you have any questions on above compose.


Viewing all articles
Browse latest Browse all 10548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>