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

Query on Read table....

Former Member
0 Likes
568

Hi All,

I am new to ABAP. I want to know wherether it is better to fire a READ TABLE based on key or index.

Which one would be faster ?

thanks in advance,

Ashish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
544

Index will be faster to start with,

but if you use BINARY SEARCH addition when you use KEY, then the serach speed will increase considerably.

to use BINARY SEARCH addition in READ statement, the internal table must be sort by the key you are using to search.

Regards,

Ravi Kanth Talagana

4 REPLIES 4
Read only

Former Member
0 Likes
545

Index will be faster to start with,

but if you use BINARY SEARCH addition when you use KEY, then the serach speed will increase considerably.

to use BINARY SEARCH addition in READ statement, the internal table must be sort by the key you are using to search.

Regards,

Ravi Kanth Talagana

Read only

0 Likes
544

Hi All,

Thanks for your suggestions !!!

Best Regards,

Ashish

Read only

Former Member
0 Likes
544

An INDEXed READ will be faster than a BINARY SEARCH.

Rob

Read only

Former Member
0 Likes
544

Your question does not really make sense, reading with key or index are not equal

options. Usually you will know the key, but rarely the index! The index is only know, if you work inside a loop on the same table.

Use search blog and my last name 'boes' there is a blog with extensive runtime measurements!

Binary search splits to table into halves and reduces this until the correct line is found,

so the runtime grows logarithmically with the size of the table ( N = number of lines).

Standard tables allow binary search, sorted tables have automatically a binary search.

Index search jump directly to the wanted line, i.e independent of the table size. Also hashed

reads work like that.

Siegfried