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

Indexes

Former Member
0 Likes
677

Hi friends,

In Reports How to use Indexes.

Please give an example

With Best Regards,

sagar.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
631

Hi

Please read this information below.

The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

If you have the Index with your Where clause fields, you can use that to improve your Select statmnet performence ..

You can force the sql statement to use a particular index by using %_HINTS parameter.

For eg:

SELECT carrid connid cityfrom

FROM spfli INTO (xcarrid, xconnid, xcityfrom)

WHERE carrid = 'LH ' AND cityfrom = 'FRANKFURT'

%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'.

WRITE: / xcarrid, xconnid, xcityfrom.

ENDSELECT.

Refer to the SAP Note #129385 and related notes for further information

----


if the table you are using has an index you can try and get sql to use it by coding the fields of the index in the where clause of your select (in the same sequence as they appear in the index). Use ST05 to explain your sql if you can and this should confirm/deny whether your code uses an index or not.

----


Check...

sap.ittoolbox.com/documents/popular-q-and-a/specifying-the-index-to-be-used-2462

sap.ittoolbox.com/documents/popular-q-and-a/specifying-the-index-to-be-used-2462

http://www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases...

Quick Note on Design of secondary database indexes and logical databases

Secondary Database

First it must be stated that table design is a more logical work while index design is rather technical. In table design it might make sense to place certain fields (client, company code, ...) in the beginning. In index design, this is not advisable. Very important for an index is that it contains very selective fields in the beginning. Those are fields like object numbers. Not selective are client, company code, ...

Indexes should be small (few fields). The Database optimizer can combine two or more indexes to execute a query.

Indexes of one table should be disjoint (have few common fields), in order not to confuse the optimizer which index to use.

Note that each index slows the inserts into the table down. Updates are only slowed down if indexed fields are updated. In general, heavy inserted tables should have only few indexes while heavy selected tables might have more.

----


Hope this will help.

Please reward suitable points.

Regards

- Atul

Hi friends,

In Reports How to use Indexes.

Please give an example

With Best Regards,

sagar.

4 REPLIES 4
Read only

Former Member
0 Likes
632

Hi

Please read this information below.

The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.

If you have the Index with your Where clause fields, you can use that to improve your Select statmnet performence ..

You can force the sql statement to use a particular index by using %_HINTS parameter.

For eg:

SELECT carrid connid cityfrom

FROM spfli INTO (xcarrid, xconnid, xcityfrom)

WHERE carrid = 'LH ' AND cityfrom = 'FRANKFURT'

%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'.

WRITE: / xcarrid, xconnid, xcityfrom.

ENDSELECT.

Refer to the SAP Note #129385 and related notes for further information

----


if the table you are using has an index you can try and get sql to use it by coding the fields of the index in the where clause of your select (in the same sequence as they appear in the index). Use ST05 to explain your sql if you can and this should confirm/deny whether your code uses an index or not.

----


Check...

sap.ittoolbox.com/documents/popular-q-and-a/specifying-the-index-to-be-used-2462

sap.ittoolbox.com/documents/popular-q-and-a/specifying-the-index-to-be-used-2462

http://www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases...

Quick Note on Design of secondary database indexes and logical databases

Secondary Database

First it must be stated that table design is a more logical work while index design is rather technical. In table design it might make sense to place certain fields (client, company code, ...) in the beginning. In index design, this is not advisable. Very important for an index is that it contains very selective fields in the beginning. Those are fields like object numbers. Not selective are client, company code, ...

Indexes should be small (few fields). The Database optimizer can combine two or more indexes to execute a query.

Indexes of one table should be disjoint (have few common fields), in order not to confuse the optimizer which index to use.

Note that each index slows the inserts into the table down. Updates are only slowed down if indexed fields are updated. In general, heavy inserted tables should have only few indexes while heavy selected tables might have more.

----


Hope this will help.

Please reward suitable points.

Regards

- Atul

Read only

0 Likes
631

This is a bad thing as you have now made your code DB dependant.

To answer more generally the question:

Use the Where clause in the select with the field order the same as in the index.

Beyond that go to an advanced SQL course.

Enjoy

Read only

Clemenss
Active Contributor
0 Likes
631

Satya,

Indexes are used to speed up the process of retrieving one or more records from database or in internal table.

For database access, key fields should be used in the WHERE clause. If the index is made of more than one field, you must use the first if you want to use the second field and so on. The database interface will find out which index can be used best making the given example with HINTS obsolete.

You can also declare internal tables with indexes, see online help for SORTED and HASHED tables.

Regards,

Clemens

Read only

abdul_hakim
Active Contributor
0 Likes
631

hi satya,

Index will speedup the database access and obviously it will improve ur report performance.make use of primary/secondary indexes for better performance.

Cheers,

Hakim

Mark all useful answers.....