Execute the parallelizable UDR

When a query with a parallelizable UDR executes in parallel, each routine instance might have more than one routine sequence. For a parallelized UDR, the routine manager creates a routine sequence for each scan thread of the query.

For example, suppose you have the following query:
SELECT a_func(x)
FROM table1
WHERE a_func(y) > 7;
Suppose also that the table1 table in the preceding query is fragmented into four fragments and the a_func() user-defined function was registered with the PARALLELIZABLE routine modifier. When this query executes in serial, it contains two routine instances (one in the select list and one in the WHERE clause) and two routine sequences. However, when this query executes in parallel over table1, it still contains two routine instances but it now has six routine sequences:
  • One routine sequence for the primary thread to execute a_func() in the select list.
  • Five routine sequences for a_func() in the WHERE clause:
    • One routine sequence for the primary thread
    • Four routine sequences for secondary PDQ threads, one for each fragment in the table
The MI_FPARAM structure holds the information of the routine sequence. Therefore, the routine manager allocates an MI_FPARAM structure for each scan thread of the parallelized query. All invocations of the UDR that execute in the scan thread can share the information in an MI_FPARAM structure. However, UDRs in different scan threads cannot share MI_FPARAM information across scan threads.
Tip: The DataBlade® API also supports memory locking for a parallelizable UDR that shares data with other UDRs or with multiple instances of the same routine. Memory locking allows the UDR to implement concurrency control on its data; however, the memory-locking feature is an advanced feature of the DataBlade API. For more information about the memory-locking feature, see Handling concurrency issues.

For more information about how the routine manager creates a routine sequence, see Create the routine sequence.