Skip to Content
author's profile photo Former Member
Former Member

Performance of collect statement

Hi Experts,

I have a doubt regarding the performance of collect statement. Is it faster using collect statement or is it faster using read statement and performing the calculations manually. Please advise me. thanks.

regards.

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Posted on Jan 04, 2008 at 12:40 AM

    Hi,

    The runtime of a COLLECT increases with the width of the table key and the number of numeric fields whose contents are summated.

    It depends on how many records you are going to process.

    Read with binary search will definately improve the performance.

    Reward if helpful.

    Regards,

    Rahul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2008 at 12:56 AM

    If the Records are less, Read is not BAD. But if the records are more, >1000, Collect is the way to go!!!

    READ BINARY runs in less time, and the internal table's index must be adjusted with each iteration.

    COLLECT, however, uses a hash algorithm and is therefore independent of the number of entries and does not need to maintain a table index. If you need the final data sorted, sort it after all data has been collected.

    If the amount of data is small, the READ approach isn't bad, but for larger amounts of data (>1000), COLLECT is much faster.

    Caution:

    When you fill an internal table, do not use COLLECT in combination with any other table-filling statements (APPEND, INSERT, MODIFY, SELECT * INTO TABLE and/or SELECT * APPENDING TABLE).

    If you mix COLLECT with the other statements, COLLECT cannot use its hash algorithm. In this case, COLLECT resorts to a normal linear search, which is dramatically slower:

    Hope this helps.

    Vinodh Balakrishnan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 04, 2008 at 03:55 AM

    Hi,

    to performing the calculations like totals, subtotals choose the collect statement . it is faster than the read statement.

    read statement check the record by record in the internal table.

    wheras collect will do the calculations in the work area and pu t into the internal table level.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2008 at 01:49 PM

    Hi,

    Collect and Append act as same if u have distinct records based on primary key or non numeric field.

    For eg. if i wanted to append emp id 101 to an internal table having 100 employees starting from emp id 001 to 100 then i can do it using both collect and append.

    Now Collect is differnt if an internal table is having numeric and non numeric values

    For eg. If i have internal table having Emp id and Reimbursements and i wanted to add more reimburesemnt for same emp id say 100 then Append will add one more record to same internal table while collect will add the reimbursements and will show only one record for each emp id say 100.

    If Internal table is sorted then the performance improves .

    PS: Reward points if Helpfull

    Regards

    Naveen Gupta

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.