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

tables

Former Member
0 Likes
629

what r secondary indices ?plz explain me

1 ACCEPTED SOLUTION
4 REPLIES 4
Read only

Former Member
0 Likes
605

Hi pinky,

1. SECONDARY INDEX.

They are generally used for faster access.

EG.

In a table there are 10 fields.

1,2 are primary fields (primary index)

2. But the table is queried many times

on field number 6 (eg).

So we can create a NEW Index

(Secondary index)

only on that 6th field.

3. Due to this,

the sql will become faster

because NOW

the database will search on the

basis of secnodary index (made on 6th field)

regards,

amit m.

Read only

Former Member
0 Likes
605

Hi!

Documentation

If you need to access an internal table with different keys

repeatedly, keep your own secondary indices.

With a secondary index, you can replace a linear search with a

binary search plus an index access.

  • Entries: 1000, Line width: 100

  • Key width: 20

  • The READ locates the 500th entry.

READ TABLE ITAB INTO WA

WITH KEY DATE = SY-DATUM.

IF SY-SUBRC = 0.

" ...

ENDIF.

  • Entries: 1000, Line width: 100

  • Key width: 20

  • The READ locates the 500th entry.

READ TABLE SEC_IDX INTO SEC_IDX_WA

WITH KEY DATE = SY-DATUM

BINARY SEARCH.

IF SY-SUBRC = 0.

READ TABLE ITAB INTO WA

INDEX SEC_IDX_WA-INDX.

" ...

ENDIF.

Read with Binary search improves the performance.

Consider the following example.

In linear search If you are searching for a number 99 in a set of 100 numbers, you would hit the number 99 in the 99th time.

If you do it the binary way, you can get it in much lesser passes.

split the 100 numbers into two parts.

less than 50 and greater than 50.

If your number (99) is not there in the first part, you don;t need to search that set of 50 numbers at all.

Now, you have to search for only the second set of 50 numbers that is 51-100 only.

Again split the fifty numbers into two.

51-75 anf 76-100.

99 doesn't lie in 51-75.

It should be there in 76-100 only..so discard the 51-75 set.

Continue this process until you find the number.

Which would be less than 10 chances compared to 99 chances in linear search.

Regards

Tamá

Read only

Former Member
0 Likes
605

Hi ..

U can see this useful link for wholesome info :

<b>http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eb20446011d189700000e8322d00/content.htm</b>