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_member445996
Participant
0 Likes
1,956

Hi All,

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

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,898

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

Hi All,

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

Thanks

10 REPLIES 10
Read only

Former Member
0 Likes
1,898

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

Read only

Former Member
0 Likes
1,898

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

Read only

0 Likes
1,898

Aurang,

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

Read only

Former Member
0 Likes
1,898

Hai Aurang

check the link

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

Thanks & regards

Sreenivasulu P

Read only

Former Member
0 Likes
1,898

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

Read only

Former Member
0 Likes
1,898

HI

GOOD

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

THANKS

MRUTYUN

Read only

Former Member
0 Likes
1,898

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

Read only

Former Member
0 Likes
1,899

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

Read only

Former Member
0 Likes
1,898

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.

Read only

Former Member
0 Likes
1,898

Aurang,

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