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

Reducing Data base selection time

Former Member
0 Likes
687

Hi,

I need to get the Excise Documnets which are not Billed. For that I've used following logic. But it is taking much time to get the data.

SELECT a~exnum

a~exyear

a~exdat

a~rdoc2

SUM( a~exbed )

SUM( a~ecs )

SUM( a~exaddtax1 )

b~vbtyp

b~knumv

b~bukrs

b~kunrg

FROM j_1iexcdtl AS a INNER JOIN vbrk AS b

ON ardoc2 EQ bvbeln

INTO TABLE lt_excise WHERE a~exdat IN s_fkdat AND

a~status EQ 'C' AND

  • a~exdat ge '20090401' AND

NOT EXISTS ( SELECT vbeln FROM vbrk WHERE vbeln EQ a~rdoc3 AND

vbtyp EQ 'M' ) AND

b~vbtyp EQ 'U' AND

b~bukrs IN s_bukrs AND

b~kunrg IN s_kunrg

GROUP BY a~exnum

a~exyear

a~exdat

a~rdoc2

b~vbtyp

b~knumv

b~bukrs

b~kunrg.

Pl help to reduce the time for database selection.

Regards,

Rajiv. V

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
651

Hi,

Try to split this into two.

First try to fetch the sales order which are required.

Then use this sales order in second query to find excise related data with for example for all entries.

This will improve the performance.

Regards,

Sunny

4 REPLIES 4
Read only

Former Member
0 Likes
652

Hi,

Try to split this into two.

First try to fetch the sales order which are required.

Then use this sales order in second query to find excise related data with for example for all entries.

This will improve the performance.

Regards,

Sunny

Read only

Former Member
0 Likes
651

Hi Vaddepati,

Also dont use aggregate functions like SUM . It also causes performance issues.

Regards

Abhii

Read only

former_member329859
Participant
0 Likes
651

HI,

Try this,

Firstly take data using select * from table command on transperent tables,

and within the loop use select single and read table commands

Regards

Gaurav

Read only

Former Member
0 Likes
651

Hi,

To decrease the load on DB ,you can process Group by and SUM functions in Loop Endloop of resulting table.

Avoid using Subqueries with not condition.I read ,NOT compromises the index and starts linear search.

There are already many discussions on usage on For all entries and Join .So search forum for more details.

The performance of join and For all entries are context oriented.


SELECT a~exnum
a~exyear
a~exdat
a~rdoc2
SUM( a~exbed )                 "  Avoid using SUM use Control break in loop endloop
SUM( a~ecs )
SUM( a~exaddtax1 )
b~vbtyp
b~knumv
b~bukrs
b~kunrg
FROM j_1iexcdtl AS a INNER JOIN vbrk AS b
ON a~rdoc2 EQ b~vbeln   "Rdoc2 is available in secondary index ,I am not sure whether this affects the performance ,EXPERT advice is required     
INTO TABLE lt_excise WHERE a~exdat IN s_fkdat AND      
a~status EQ 'C' AND                             
* a~exdat ge '20090401' AND                 "if possible, try to use  indexed fields from VBRK 
NOT EXISTS ( SELECT vbeln FROM vbrk WHERE vbeln EQ a~rdoc3 AND   "Avoid using Not this would compromise the index or use Delete itab on resulting table
vbtyp EQ 'M' ) AND                                                                                
b~vbtyp EQ 'U' AND   
b~bukrs IN s_bukrs AND
b~kunrg IN s_kunrg
GROUP BY a~exnum                       " Avoid Group by 
a~exyear
a~exdat
a~rdoc2
b~vbtyp
b~knumv
b~bukrs
b~kunrg.