Adding hints in SELECT clause
If there are many indexes that contain common fields (or for any other reason), the database optimizer cannot decide the right index to be used for a particular query, and then use a wrong index that may not be of optimal performance. From SAP Release 4.5, hints can be provided using the %_HINTS
parameter. In this recipe, we will see the syntax for specifying HINTS
within your SELECT
clause in order for a particular index to be used by the database optimizer. We will see how the hints may be specified when the underlying database is MS SQL Server.
Getting ready
In this recipe, we will have a small program that runs a SELECT
statement on the table ZST9_VBAK
. We will use the index (Z12
) that we created in the previous Creating Secondary Indexes in Database Tables recipe.
How to do it...
For creating the program containing the SELECT
clause with the HINT
parameter, proceed as follows:
A parameter
P_AUFNR
is declared for taking as input an order number.Next, a data variable...