Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to improve Performance for Select statement

Former Member
0 Likes
437

Hi Friends,

Can you please help me in improving the performance of the following query:

SELECT SINGLE MAX( policyterm ) startterm INTO (lv_term, lv_cal_date) FROM zu1cd_policyterm WHERE gpart = gv_part GROUP BY startterm.

Thanks and Regards,

Johny

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
410

long lists can not be produced with a SELECT SINGLE, there is also nothing to group.

But I guess the SINGLE is a bug

 
SELECT MAX( policyterm ) startterm 
              INTO (lv_term, lv_cal_date) 
              FROM zu1cd_policyterm 
              WHERE gpart = gv_part 
              GROUP BY startterm.

How many records are in zu1cd_policyterm ?

Is there an index starting with gpart?

If first answer is 'large' and second 'no' => slow

What is the meaning of gpart? How many different values can it assume?

If many different values then an index makes sense, if you are allowed to create

an index.

Otherwise you must be patient.

Siegfried

3 REPLIES 3
Read only

Former Member
0 Likes
410

Hi,

Do you really need the GROUP BY ? Try doing the processing after fetching records instead of GROUP BY .

Regards,

Deepthi

Read only

Former Member
0 Likes
410

If you have very large data in table zu1cd_policyterm then GROUP BY will work very slow. Else select data into in interal table and do processing.

Read only

Former Member
0 Likes
411

long lists can not be produced with a SELECT SINGLE, there is also nothing to group.

But I guess the SINGLE is a bug

 
SELECT MAX( policyterm ) startterm 
              INTO (lv_term, lv_cal_date) 
              FROM zu1cd_policyterm 
              WHERE gpart = gv_part 
              GROUP BY startterm.

How many records are in zu1cd_policyterm ?

Is there an index starting with gpart?

If first answer is 'large' and second 'no' => slow

What is the meaning of gpart? How many different values can it assume?

If many different values then an index makes sense, if you are allowed to create

an index.

Otherwise you must be patient.

Siegfried