05-09-2006 2:30 PM
Hi All,
Is there a way to specify which index to use in the select statement?
Thanks
05-09-2006 3:07 PM
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
05-09-2006 2:32 PM
i think it will depend on the fields which u will be using in the select statement and fields for which indexes are created
05-09-2006 2:32 PM
Use the word "HINT" with the index name in your SELECT statement.
05-09-2006 2:39 PM
Aurang,
Also - look in OSS for notes about the "HINT" syntax in Open SQL. There are examples there for you to review.
05-09-2006 2:33 PM
Hai Aurang
check the link
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm
Thanks & regards
Sreenivasulu P
05-09-2006 2:34 PM
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
05-09-2006 2:36 PM
HI
GOOD
WHERE YOU ACTUALLY WANT TO SPECIFY YOUR INDEX WHEATHER IN A SQL QUERY OR SOMEWHERE ELSE.
THANKS
MRUTYUN
05-09-2006 2:38 PM
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
05-09-2006 3:07 PM
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
05-09-2006 3:14 PM
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.
05-09-2006 3:36 PM
Aurang,
If your question has been answered, don't forget those points and close the thread.