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

index

Former Member
0 Likes
581

what is performance of select single statement?

what is the use of secondary index?

4 REPLIES 4
Read only

former_member69765
Contributor
0 Likes
549

Select single is obviously faster than other select.

It also depends on how many primary keys have you specified.

the secondary indexing is done to make the searching fast.

the searching time can be reduced by indexing the records. All the tables are by default indexed by the its primary keys. Depending on the requirement you can have other indexes also.

Read only

Former Member
0 Likes
549

1. SELECT SINGLE is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search. It selects the first row in the database that it finds that fulfils the 'WHERE' clause. If this results in multiple records then only the first one will be returned and therefore may not be unique.

If the full key is not specified in a 'SELECT SINGLE' you get a warning message in the Extended Program Check.

2. You can also create further indexes (other than primary indexex) on a table in the ABAP Dictionary. These are called <b>secondary indexes</b>. This is necessary if the table is frequently accessed in a way that does not take advantage of the sorting of the primary index for the access.

How well an existing index supports data selection from a table largely depends on whether the data selected with the index represents the data that will ultimately be selected.

An index is defined on fields FIELD1, FIELD2, FIELD3 and FIELD4 of table BSPTAB in this order. This table is accessed with the SELECT statement:

SELECT * FROM BSPTAB WHERE FIELD1 = X1 AND FIELD2 = X2 AND FIELD4= X4.

Since FIELD3 is not specified more exactly, only the index sorting up to FIELD2 is of any use. If the database system accesses the data using this index, it will quickly find all the records for which FIELD1 = X1 and FIELD2 = X2. You then have to select all the records for which FIELD4 = X4 from this set.

The order of the fields in the index is very important for the accessing speed. The first fields should be those which have constant values for a large number of selections. During selection, an index is only of use up to the first unspecified field.

Only those fields that significantly restrict the set of results in a selection make sense for an index.

Additional indexes can also place a load on the system since they must be adjusted each time the table contents change. Each additional index therefore slows down the insertion of records in the table.

For this reason, tables in which entries are very frequently written generally should only have a few indexes.

Creating an additional index could also have side effects on the performance. This is because an index that was used successfully for selection might not be used any longer by the optimizer if the optimizer estimates (sometimes incorrectly) that the newly created index is more selective.

The indexes on a table should therefore be as disjunct as possible, that is they should contain as few fields in common as possible. If two indexes on a table have a large number of common fields, this could make it more difficult for the optimizer to choose the most selective index.

http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21eb20446011d189700000e8322d00/content.htm

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

Former Member
0 Likes
549

if you are selecting with complete key, the best option is select single.<br>

the indexes are automatically created on primary keys.<br>

if you are hitting database very frequently with field other than primary keys,<br>

for the performanance issue, we make secondary indexes.<br>

bsed on the field specified in the where clause, its responsiblity of 'database optimizer' to select the secondary index.

Read only

Former Member
0 Likes
549

SELECT SINGLE IS USED TO SLECT A SINGLE RECORD BASED ON CONDITION GIVEN.

EX:

SELECT SINGLE * FROM MARA INTO TABLE ITAB WHER E MATNR = '000001'.

THE STATEMENT'S PERFORMANCE IS FASTER THAN NORMAL SELECT.

AND THE SECONDARY INDEX IS COMPARITIVELY SLOW. BZ THE CONTROL SEARCHES ALL THE RECORDS IN THE DATABASE WHEN WE USE THIS. WHERE AS IN SELECTSINGLE DIRECTLY GOES TO THE RECORD AND PICKS IT.

THANX.