Describes the query plan used for a UDR invocation. More...
#include <sqludr.h>
Inherits tmudr::TMUDRSerializableObject.
Public Types | |
enum | SpecialDegreeOfParallelism { ANY_DEGREE_OF_PARALLELISM = 0, DEFAULT_DEGREE_OF_PARALLELISM = -1, MAX_DEGREE_OF_PARALLELISM = -2, ONE_INSTANCE_PER_NODE = -3 } |
Special degrees of parallelism. More... | |
Public Member Functions | |
int | getPlanNum () const |
long | getCostPerRow () const |
int | getDesiredDegreeOfParallelism () const |
void | setCostPerRow (long nanoseconds) |
void | setDesiredDegreeOfParallelism (int dop) |
UDRWriterCompileTimeData * | getUDRWriterCompileTimeData () |
void | setUDRWriterCompileTimeData (UDRWriterCompileTimeData *compileTimeData) |
void | addPlanData (const char *planData, int planDataLength) |
const char * | getPlanData (int &planDataLength) |
void | print () |
Describes the query plan used for a UDR invocation.
Objects of this type are used together with UDRInvocationInfo objects and they contain additional info on plan-related such as the chosen partitioning and ordering.
Special degrees of parallelism.
Values that can be used in the setDesiredDegreeOfParallelism() method, in addition to positive numbers for the degree of parallelism (DoP).
void UDRPlanInfo::addPlanData | ( | const char * | planData, | |
int | planDataLength | |||
) |
Attach a byte array to the plan to be sent to the runtime instances.
Compile time and runtime interfaces of the UDR can be called from different processes, since UDRs can be executed in parallel and on different nodes. If the UDR writer would like to carry state from the compiler interface calls to runtime calls, the best way to achieve this to attach it using this call and to retrieve the state at runtime using the getPlanData() call.
The best place to use this method is from within UDR::completeDescription() method, since this method is called on the optimal plan that will be used at runtime. It can also be called from other methods, and the plan data will be discarded if the plan is not chosen.
planData | A byte array, content defined by the UDR writer, to be sent to all runtime instances executing the UDR. The buffer can and should be deleted by the caller after calling this method. | |
planDataLength | Length, in bytes, of the planData. |
UDRException |
long UDRPlanInfo::getCostPerRow | ( | ) | const |
Get the cost of the UDR per row, approximately in nanoseconds.
int UDRPlanInfo::getDesiredDegreeOfParallelism | ( | ) | const |
Return the desired degree of parallelism for this plan.
const char * UDRPlanInfo::getPlanData | ( | int & | planDataLength | ) |
Retrieve plan data attached to the UDR invocation and plan.
This method can be called at runtime to get state generated at compile time.
planDataLength | (out) Length of returned plan data. |
int UDRPlanInfo::getPlanNum | ( | ) | const |
Get a unique id for a given plan within a UDR invocation.
UDRWriterCompileTimeData * UDRPlanInfo::getUDRWriterCompileTimeData | ( | ) |
Get data to persist between calls of the optimizer interface
UDRException |
void UDRPlanInfo::print | ( | ) |
Print the object, for use in debugging.
void UDRPlanInfo::setCostPerRow | ( | long | nanoseconds | ) |
Set the cost of the UDR per row, approximately in nanoseconds.
Specifying a cost can help with query plan issues. Note that the operator cost ("EST_OPER_COST") in EXPLAIN is not directly related to the nanosecond value specified here:
The default implementation estimates the cost to be approximately 100 * sqrt(out().getRecordLength()). Therefore, a value of 1000 might be a good starting point for a cost per row estimate, assuming an output row length of about 1 KB. Increase this for more complex UDFs or for wider result rows, decrease it for simpler UDFs or shorter result rows.
Only use this method from within the UDR::describeDesiredDegreeOfParallelism() method.
nanoseconds | Cost of the UDR per row, in nanoseconds, for optimization purposes. |
void UDRPlanInfo::setDesiredDegreeOfParallelism | ( | int | dop | ) |
Set the desired degree of parallelism.
Only use this method from within the UDR::describeDesiredDegreeOfParallelism() method.
Here are some special values that can be set, in addition to positive numbers. These are defined in class UDRPlanInfo.
ANY_DEGREE_OF_PARALLELISM:
This will allow the optimizer to choose any degree of parallelism, including 1 (serial execution) DEFAULT_DEGREE_OF_PARALLELISM:
Currently the same as ANY_DEGREE_OF_PARALLELISM. The optimizer will use a heuristic based on the estimated cardinality. MAX_DEGREE_OF_PARALLELISM:
Choose the highest possible degree of parallelism. ONE_INSTANCE_PER_NODE:
Start one parallel instance on every Trafodion node. This is mostly meant for internal TMUDFs, e.g. a TMUDF to read the log files on every node.dop | desired degree of parallelism (a positive number or one of the enum values in UDRPlanInfo::SpecialDegreeOfParallelism). |
UDRException |
void UDRPlanInfo::setUDRWriterCompileTimeData | ( | UDRWriterCompileTimeData * | compileTimeData | ) |
Set data to persist between calls of the optimizer interface
This call can be used to attach an object derived from class UDRWriterCompileTimeData to the UDRPlanInfo object. Once attached, the data will be carried between the stages of the optimizer interface and can be used to keep state. Note that this data will be deleted at the end of the optimizer phase and will not persist until runtime.
Use this method to keep data that is specific to a query plan alternative, represented by the UDRPlanInfo object. Use UDRInvocationInfo::setUDRWriterCompileTimeData() to keep data that is common for the entire UDR invocation.
compileTimeData | UDR writer-defined compile-time data to attach. |
UDRException |