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

select with loop

umayaraj
Participant
0 Likes
1,227

hi,

i have performance issue with below code

LOOP AT it_dd02l ASSIGNING FIELD-SYMBOL(<wa_dd02l>).
    SELECT COUNT(*) FROM (<wa_dd02l>-tabname) INTO count_temp.
...
ENDLOOP.

My Requirement is find All traction table with total no of records .

any one have better solution for above code

4 REPLIES 4
Read only

Patrick_vN
Active Contributor
0 Likes
1,133

I'm not sure you can improve the SQL statement. An option would be to foresee some parallelization, and thus run x SQL statements at a time (by using an RFC that returns the amount of documents of a certain (number of) table(s)), That way when one batch/RFC is done, you can trigger another etc.

example 'pseudo' code:

  CALL FUNCTION '[Your Function]'
    STARTING NEW TASK [taskname]
    DESTINATION IN GROUP [server_group]
    PERFORMING [Retrieve Info Form] ON END OF TASK
    EXPORTING
      ..
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,133

It takes a while to count the number of records of each table (especially big ones). It used to be counted approximately on Oracle database via the statistics, to determine the best execution plans, for performance purpose. What is your database software? Do you really need to have an exact count rather than an approximate one? Can't you use other measurement means like number of blocks to know the size on disk? (it may count unused space and deleted records)

Read only

umayaraj
Participant
0 Likes
1,133

Hi sandra,

DataBase: Oracle

id Native SQL Not Recommended to run Production system right?

and Native SQL DB Statics Give All Clients information We can't to split Client based Info.

Read only

Sandra_Rossi
Active Contributor
1,133

If you can't make it work "normally", you have to find an "abnormal" solution, it's not forbidden to write native SQL. By the way, why do you want to create an ABAP program for a technical database feature?

You're right about client. Do you really have a multi-client system?

I think you may find better answers in an Oracle forum. Or go for Patrick solution to parallelize the count (you may also easily parallelize Oracle SQL).