Modulus partitioned read method

When this method is selected, for each node, the connector reads the rows that satisfy the following condition: ABS(MOD(column_name, number_of_nodes)) = node_number. In this condition, ABS returns the absolute value of the argument, MOD is the modulus function, column_name is the name of the column that is specified in the Partitioned reads method > Column name property, number_of_nodes is the total number of nodes on which the stage runs, and node_number is the index of the current node.

The indexes are zero-based. Therefore, the first node has index 0, the second node has index 1, and so on.

To use this method, you must specify a column name from the source table in the Partitioned reads method > Column name property. The column that you specify must be a numeric data type that is supported by the MOD() function of Db2. For more information, refer to MOD and ABS functions description in the IBM Db2 Knowledge Center.The specified column must exist in the table that is specified in the Usage > Table name property or the Select statement property. The value for the Select statement property is used only if the Generate SQL property is set to No.

Example of using the modulus partitioned read method

For this example, the Db2 connector is configured in the following way:
  • The Generate SQL property is set to No.
  • The Select statement property is set to SELECT * FROM TABLE1 WHERE COL1 > 10.
  • The connector is configured to run in parallel mode on four nodes.
  • The Partitioned reads method property is set to Modulus
  • The Column name property is set to COL2, and COL2 is defined as INTEGER in TABLE1.
The connector runs the following SELECT statements on the nodes:
Node 1
SELECT * FROM TABLE1 WHERE ABS(MOD(COL2, 4)) = 0 AND (COL1 > 10)
Node 2
SELECT * FROM TABLE1 WHERE ABS(MOD(COL2, 4)) = 1 AND (COL1 > 10)
Node 3
SELECT * FROM TABLE1 WHERE ABS(MOD(COL2, 4)) = 2 AND (COL1 > 10)
Node 4
SELECT * FROM TABLE1 WHERE ABS(MOD(COL2, 4)) = 3 AND (COL1 > 10)