Application Development 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: 

Use two secondary indexes in a select statement

Former Member
0 Kudos

hi, i want to use two secondary indexes in a select statement.

how can i do it?

1 ACCEPTED SOLUTION

valter_oliveira
Active Contributor
0 Kudos

Hello.

What do you mean by using two secondary indexes? Remember that the optimizer will choose the best index to use, considering the fields you used in the query. This means that you can use fields of more than one index in the "where" condition, but the optimizer can only choose one.

Use tcode ST05 to see how it works.

Hope this helps you.

Regards.

Valter Oliveira.

10 REPLIES 10

valter_oliveira
Active Contributor
0 Kudos

Hello.

What do you mean by using two secondary indexes? Remember that the optimizer will choose the best index to use, considering the fields you used in the query. This means that you can use fields of more than one index in the "where" condition, but the optimizer can only choose one.

Use tcode ST05 to see how it works.

Hope this helps you.

Regards.

Valter Oliveira.

Former Member
0 Kudos

thanks valter but i need to know how i can set two indexes in a select statement.

0 Kudos

Hello,

To do it use the WHERE stm in the same order as the secondary stm is on SE11....To check if the index is used go to tcode ST05.

example

select * from ztable

WHERE BUKRS EQ 'BUK1' AND

ZFIELD EQ 'BOY'.

on se11 on the ZTABLE indexes setion must have a secondary index with

BUKRS and

ZFIELD.

BYE!!

Hope this helps!!

Gabriel

0 Kudos

Hi, you need not do any thing spl when ur using secondary index in your select statement... its just u put the where clause and system will automatically pick the best index.. based on your field being used.

Former Member
0 Kudos

hi.....

By using two secondary indeex yu are anyways not going to increase the performance.The database optimizer will decide which secondary index is best suited.

You can use both the secondary index as in normal where conndtion.When data is fteched from tha database the best will be chosen by optimizer.

Former Member
0 Kudos

ok it is correct, but what is the statement to set two indexes in a select statement.

0 Kudos

You cannot set two indexes in a select statement (afaik). If absolutely necessary (very rarely) you can force the DB to use one particular index via so called hints.

Greetings

Thomas

0 Kudos

Use the fields that are the secondary indexes in your WHERE clause. The rest will take care of itself.

Former Member
0 Kudos

hi when there is a requirement of the secodary index is given by the cleint and it is badly effect the performance and for setting the secondary index you need to contact the basis guy...generally we will not use the secondary index if not it is a special case..so i suggest you not to use the two secondary indexes in one select ...

Former Member
0 Kudos

Thanks to everyone for the answers