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

Performance increase

Former Member
0 Likes
502

Hi,

I have one condition that shouldbe satisfied for Fetching entries from a Z table which is as follows.

Dateto field can be between first and last day of consumption month or it can be greater or equal to last day.

Datefrom field can be between first and last day of consumption month or it can be less than or equal tofirst day .

i have written the following code for that but i have to reduce the number of condition for performance issue pleas suggest me if there is any better method for this.

SELECT logikzw profrole profile
    FROM eprofass
    INTO TABLE git_eprofass
    WHERE profrole  EQ 'ESOG'   AND                                                                                        
         ( ( dateto  BETWEEN p_x_setlmnth_firstday  AND p_x_setlmnth_lastday OR ( dateto GE p_x_setlmnth_lastday ) )   AND "  GE p_x_setlmnth_lastday              AND
         ( ( datefrom BETWEEN p_x_setlmnth_firstday AND p_x_setlmnth_lastday ) OR ( datefrom LE p_x_setlmnth_firstday ) ).   " LE p_x_setlmnth_firstday.
 

Thanks in advance,

Chetan

Thanks T
1 ACCEPTED SOLUTION
Read only

yuri_ziryukin
Product and Topic Expert
Product and Topic Expert
0 Likes
467

Hello Chetan,

your conditions look unnecessary complicated.

Look at the first part:

( ( dateto  BETWEEN p_x_setlmnth_firstday  AND p_x_setlmnth_lastday )  OR ( dateto GE p_x_setlmnth_lastday ) )

You can easily reduce it to

dateto GE p_x_setlmnth_firstday

And the second part of the condition

( ( datefrom BETWEEN p_x_setlmnth_firstday AND p_x_setlmnth_lastday ) OR ( datefrom LE p_x_setlmnth_firstday ) )

can be easily reduced to

datefrom LE p_x_setlmnth_lastday

This is a simple "date interval intersection" that is often used in SAP queries.

Finally your select will be:

SELECT logikzw profrole profile
    FROM eprofass
    INTO TABLE git_eprofass
    WHERE profrole  EQ 'ESOG'   AND                                                                                        
        dateto GE p_x_setlmnth_firstday   AND

        datefrom LE p_x_setlmnth_lastday. 

When you then have an index with fields "profrole", "dateto", "datefrom" (in this order), then your select should have more or less optimal performance.

Regards,

  Yuri

3 REPLIES 3
Read only

former_member282968
Contributor
0 Likes
467

This message was moderated.

Read only

0 Likes
467

Please replay if there is any alternative way to achieve select condition i have ementioned.

Read only

yuri_ziryukin
Product and Topic Expert
Product and Topic Expert
0 Likes
468

Hello Chetan,

your conditions look unnecessary complicated.

Look at the first part:

( ( dateto  BETWEEN p_x_setlmnth_firstday  AND p_x_setlmnth_lastday )  OR ( dateto GE p_x_setlmnth_lastday ) )

You can easily reduce it to

dateto GE p_x_setlmnth_firstday

And the second part of the condition

( ( datefrom BETWEEN p_x_setlmnth_firstday AND p_x_setlmnth_lastday ) OR ( datefrom LE p_x_setlmnth_firstday ) )

can be easily reduced to

datefrom LE p_x_setlmnth_lastday

This is a simple "date interval intersection" that is often used in SAP queries.

Finally your select will be:

SELECT logikzw profrole profile
    FROM eprofass
    INTO TABLE git_eprofass
    WHERE profrole  EQ 'ESOG'   AND                                                                                        
        dateto GE p_x_setlmnth_firstday   AND

        datefrom LE p_x_setlmnth_lastday. 

When you then have an index with fields "profrole", "dateto", "datefrom" (in this order), then your select should have more or less optimal performance.

Regards,

  Yuri