Application Development 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: 

How to improve Performance for Select statement

Former Member
0 Kudos

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

former_member194613
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi,

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

Regards,

Deepthi

Former Member
0 Kudos

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.

former_member194613
Active Contributor
0 Kudos

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