skip to main content
Designing and coding the IP : Join processing : Join order selection : Specifying join order
 

Specifying join order

If join order selection is enabled for IP, during the query plan generation of a join, OpenAccess SDK SQL Engine calls IP EXECUTE with the statement type as DAM_SET_JOIN_ORDER. Your IP must use pass-through APIs to obtain details of a query. The IP must first call dam_getJoinQuery() to obtain the query handle and then use the pass-through mode API, damex_describeSelectQuery(), to obtain query details.
After analyzing the query details, the IP can specify the query join order. To specify the query join order, the IP must call dam_setJoinOrder() for each table in the query. The sequence in which dam_setJoinOrder() is called determines the join order for the query.
To obtain table handles, the IP must use damex_getFirstTable and damex_getNextTable APIs.

Example 

If a join query has three tables (T1, T2, T3) and you want the join order to be T2, T1, and T3, then your IP must call dam_setJoinOrder in following sequence:
dam_setJoinOrder(T2)
dam_setJoinOrder(T1)
dam_setJoinOrder(T3)
Note: If you do not provide the join order in the IP, the OpenAcess SDK SQL engine automatically determines the best join order.