Executing in parallel

Parallelizable routines can execute in parallel across multiple processors.

Before you begin

To make a UDR parallelizable, apply the following rules:
  • Follow the guidelines for well-behaved user-defined routines.
  • Avoid any DataBlade® API routine that involves query processing (mi_exec(), mi_exec_prepared_statement()), collections (mi_collection_*), row types, or save sets (mi_save_set_*).
  • Do not create rows that contain any complex types including another row type as one of the columns. Do not use the mi_row_create() or mi_value() functions with complex types or row types.
  • Avoid DataBlade API FastPath functions (mi_routine_*, mi_func_desc_by_typeid()) if the access method might pass them routine identifiers for nonparallelizable routines.
  • Specify the PARALLELIZABLE routine modifier in the CREATE FUNCTION or CREATE PROCEDURE statement for the UDR.
For more information about the following topics, see the Informix® DataBlade API Programmer's Guide:
  • Guidelines for well-behaved user-defined routines
  • A complete list of nonparallelizable functions
  • FastPath function syntax, usage, and examples

For more information about the PARALLELIZABLE (and other) routine modifiers, see the routine modifier section in the Informix Guide to SQL: Syntax. For more information about parallelizable UDRs, see Creating User-Defined Routines and User-Defined Types.

About this task

To make an access method parallelizable:

Procedure

  1. Create a basic set of parallelizable purpose functions.

    The basic set, which enables a SELECT statement to execute in parallel, includes the following purpose functions: am_open, am_close, am_beginscan, am_endscan, am_getnext, and am_rescan.

    An access method might not supply all of the purpose functions that define a basic parallelizable set. As long as you make all the basic purpose functions that you provide parallelizable, a SELECT statement that uses the access method can execute in parallel.

  2. Add a parallelizable purpose function to the basic set for any of the following actions that you want the database server to execute in parallel.
    Parallel SQL statement Parallelizable purpose function
    INSERT (in a SELECT) am_insert
    SELECT INTO TEMP am_insert
    DELETE am_delete
    UPDATE am_update

Results

Important: A parallelizable purpose function must call only routines that are also parallelizable. All the strategy and support functions for the operator class that the index uses must also be parallelizable.

The database server sets an am_parallel purpose value in the sysams system catalog table to indicate which access-method actions can occur in parallel.