Home | Previous Page | Next Page   Improving UDR Performance > Parallel UDRs >

Executing UDRs in Parallel

The database server can execute the following UDRs in parallel if they are part of a PDQ and PDQPRIORITY is turned on:

UDRs can execute in parallel in the following situations if they are part of a PDQ and PDQPRIORITY is turned on:

A UDR cannot execute the following SQL statements in parallel:

Execution of a UDR in a Query Expression

One way to execute UDRs is as an expression in a query. You can take advantage of parallel execution if the UDR is in an expression in one of the following parts of a query:

Parallel UDR in WHERE Clause

The following example is a typical PDQ that contains two UDRs:

SELECT c_udr1(tabid) FROM tab 
   WHERE tabname = c_udr2(3) AND 
      tabid > 100;

If the table tab has multiple fragments and the optimizer decides to run the select statement in parallel, the following operations can execute in parallel:

Parallel UDR in a Join

The following sample query contains a join between table t1 and t2:

SELECT t1.x, t2.y
   FROM t1, t2
   where t1.x = t2.y and
      c_udr(t1.z, t2.z, 3) > 5 and
      c_udr1(t1.u) > 4 and 
      c_udr2(t2.u) < 5;

If the tables t1 and t2 have multiple fragments and the optimizer decides to run the select statement in parallel, the following operations can execute in parallel:

Parallel UDR in the Select List

If you use a UDR in the select list and do not specify a WHERE clause, the UDR can execute in parallel if any of the following conditions are true:

The next section shows a sample query with a UDR in the select list and no WHERE clause.

Parallel UDR with GROUP BY

The following sample query contains a GROUP BY clause. This sample query has a UDR in the select list and no WHERE clause.

SELECT c_udr1(tabid), COUNT(*)
   FROM t1 GROUP BY 1;

If the optimizer decides to run the select statement in parallel, the following operations can execute in parallel:

Parallel UDR in Select List for Parallel Insert

The following sample query is a parallel insert statement. Suppose you create an opaque data type circle, create a table cir_t that defines a column of type circle, create a UDR area, and then execute the following sample query:

INSERT INTO cirt_t_target
SELECT circle, area(circle) 
   FROM cir_t
   WHERE circle > "(6,2,4)";

In this query, the following operations can execute in parallel:

FastPath Execution of a UDR in a DataBlade API (C)

A C UDR can use the following DataBlade API calls to invoke a UDR directly:

DataBlade API FastPath execution of a UDR executes in parallel as long as the UDR is parallelizable and calls only DataBlade API functions that are PDQ thread safe.

Implicit UDR Execution of a User-Defined Aggregate

A user-defined aggregate (UDA) can execute in parallel as long as the UDR is parallelizable and calls only DataBlade API functions that are PDQ thread safe.

For example, suppose you create a UDA named uda and use it in the following SQL query:

select grp, uda(udt_col) FROM tab GROUP BY grp;

If the data type of column udt_col is a UDT whose aggregation requires a UDR call, the following operations can execute in parallel:

Implicit UDR Execution of a Comparison Operator

When you create opaque data types, you can create overloaded routines for comparison operators such as equal (=) or greaterthanorequal (>=).

The following sample query selects rows using a filter on the UDT column:

SELECT * FROM tab WHERE udt_col = "xyz";

The database server converts the comparison operator = to call the equal UDR on the udt_col column. If the table tab is fragmented, the following operations can execute in parallel:

Implicit Execution of an Assign UDR

When you create opaque data types, you create the support function assign() to insert, update, or load the UDT data in the table.

The following sample SQL statement inserts data in a UDT column:

INSERT INTO tab (udtcol) SELECT udtcol FROM t1;

If the table tab has multiple fragments and the udtcol data type has an assign() function, each insert thread that inserts a fragment of table tab executes the assign() UDR in parallel.

The support function destroy() for a UDT does not execute in parallel because the destroy() UDR is called during a DELETE statement that is not executed in parallel.

Execution of a Comparison UDR for Sort

When you create opaque data types, you create the support function compare() to sort the UDT data during ORDER BY, UNIQUE, DISTINCT, and UNION clauses and CREATE INDEX operations.

SELECT udtcol FROM t ORDER BY 1;

If the udtcol column has a comparison UDR that is parallelizable and the client enables parallel sort, each sort thread participating in the parallel sort for the order by clause executes the comparison UDR in parallel.

Execution of a UDR by an Index on a UDT column

The database server supports indexing on a uDT column. Therefore, index build, search, and recovery require execution of UDRs that operate on UDT columns.

Currently, the database server does not support fragmentation by expression on UDT columns. As a result, the index built on a UDT column by the database server is not fragmented because index fragmentation makes sense only if the fragmentation is based on expression.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]