skip to main content
OpenAccess SDK SQL Engine Core Functions API : Function Reference : dam_getOptimalIndexAndConditions
 

dam_getOptimalIndexAndConditions

This function is used to support single or multiple column indexes. Use this function to get the optimal index and the set of search conditions associated with the columns of that index. This information is used by the IP to restrict the rows that are read.
Each condition list contains conditions on all or some of the columns in the index. The relationship between the individual condition elements in the list is that of AND. This means that each row that the OpenAccess SDK SQL engine builds for a condition list must satisfy all the conditions in that list and must then be validated using the dam_isTargetRow function. The order of the conditions corresponds to the order of the columns in the index. The relationship between each of the condition lists is that of OR. This means that the IP builds a set of rows for each of the condition lists.
Note: You must set up the following requirements so that the OpenAccess SDK SQL engine can generate an optimal index:
*One or more column names must be marked as having an index in the OA_STATISTICS table.
*Support for one or more operators must be enabled.
int dam_getOptimalIndexAndConditions(
DAM_HSTMT hstmt,
DAM_HINDEX * phIndex,
DAM_HSET_OF_CONDLIST * phSetOfCondList)
Table 144. Properties of dam_getOptimalIndexAndConditions
Parameter
Type
Description
IN
hstmt
DAM_HSTMT
Statement handle.
OUT
phIndex
DAM_HINDEX *
The handle of the index identified as the optimal for the statement. This value is NULL if no optimal index was identified. Use the function dam_describeIndex to get details about the index, and dam_getFirstIndexCol, dam_getNextIndexCol, and dam_describeIndexCol to get details about the columns making up the index.
phSetOfCondList
DAM_HSET_OF_​CONDLIST *
If an optimal index is found, then this is a handle to the set of conditions that are present in the query. Otherwise this is NULL. Navigate it by using the dam_getFirstCondList and dam_getNextCondList functions.
The IP must call dam_freeSetOfConditionList to this handle when finished with the query.
RETURN
int
Status of the call:
DAM_SUCCESS - on success
DAM_FAILURE - error

See also

*dam_describeIndex
*dam_describeIndexCol
*dam_freeSetOfConditionList
*dam_getFirstCondList
*dam_getNextCondList
*dam_getFirstIndexCol
*dam_getNextIndexCol
*dam_isTargetRow