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: 

Indexes

former_member445996
Participant
0 Kudos

Hi All,

Is there a way to specify which index to use in the select statement?

Thanks

1 ACCEPTED SOLUTION

former_member927251
Active Contributor
0 Kudos

Hi Anurag,

Have a look at the following code.

SELECT COUNT(*)

FROM crmd_orderadm_h

WHERE process_type IN git_t_type

AND object_type = gc_subobject

AND object_id IN git_t_no

%_HINTS ORACLE 'INDEX("CRMD_ORDERADM_H" "CRMD_ORDERADM_H~OID")'.

Here I am using the index OID defined for the table CRMD_ORDERADM_H.

<b>Please reward points and close the thread if your question has been answered.</b>

Regards,

Amit Mishra

10 REPLIES 10

Former Member
0 Kudos

i think it will depend on the fields which u will be using in the select statement and fields for which indexes are created

Former Member
0 Kudos

Use the word "HINT" with the index name in your SELECT statement.

0 Kudos

Aurang,

Also - look in OSS for notes about the "HINT" syntax in Open SQL. There are examples there for you to review.

Former Member
0 Kudos

Hai Aurang

check the link

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm

Thanks & regards

Sreenivasulu P

Former Member
0 Kudos

Database will automatically use Index based on the where clause. So always try to write where clause based on the index fields and in the same sequence.

Regards

Aman

Former Member
0 Kudos

HI

GOOD

WHERE YOU ACTUALLY WANT TO SPECIFY YOUR INDEX WHEATHER IN A SQL QUERY OR SOMEWHERE ELSE.

THANKS

MRUTYUN

Former Member
0 Kudos

Hi Khan,

You can use the fields of the index in the WHERE clause of the select statement, in the order of occurence.

Regards,

Raj

former_member927251
Active Contributor
0 Kudos

Hi Anurag,

Have a look at the following code.

SELECT COUNT(*)

FROM crmd_orderadm_h

WHERE process_type IN git_t_type

AND object_type = gc_subobject

AND object_id IN git_t_no

%_HINTS ORACLE 'INDEX("CRMD_ORDERADM_H" "CRMD_ORDERADM_H~OID")'.

Here I am using the index OID defined for the table CRMD_ORDERADM_H.

<b>Please reward points and close the thread if your question has been answered.</b>

Regards,

Amit Mishra

Former Member
0 Kudos

Hello Anurang,

The selection of index cannot be manually controlled as it is the databsae which selects the best index for execution. Howerver after saying this SAP has come up with an exception from 4.5 where u can use the keyword %HINT to force the database into using a perticular index. Please refer to OSS notes 129385.

Former Member
0 Kudos

Aurang,

If your question has been answered, don't forget those points and close the thread.