Background
When a control sheet has many rows or the process time is excessive, using parallel chains can significantly reduce the run time.
Example Scenario
Imagine you have a command group in your chain that uses a Group Iterator. In this setup, the control sheet content is retrieved from a Workiva spreadsheet using the Get Sheet Data command. The chain then repeats a set of actions for each row in the sheet. (See setup instructions here.)
If the order of execution for the control sheet rows does not matter, and each row can be processed independently, you can improve the chain’s efficiency by running them in parallel using the following steps.
Note: The steps below are based on the sample chain shown above. Please adjust as necessary for your own chain and any extra commands it may have.
Step 1: Prepare Your Primary Chain
- Delete all links between all nodes.
- Delete the CSV to JSON and Command Group nodes.
- Add an Advanced Query command from the Tabular Transformations connector and connect it to the Get Sheet Data node.
- Configure the node with the following values:
- Tables > File: select the Get Sheet Data > Data output from the Variable Panel.
- Tables > Table Name: use a name without spaces.
-
Query: use the MySQL
NTILEfunction to assign a group number to each row (e.g.,NTILE(3)for three groups).
Note: You will have to test your process to find the appropriate number of groups that aligns with your desired run time. As a best practice, the number should be less than 10.
Step 2: Set Up Your Sub-Chain to Run in Parallel
- In the sub-chain executed by your Run Chain event, either add or amend the Runtime Inputs command. A reminder this must be the first node of the chain. Configure two inputs for it: one FileField input for the data file and one NumberField input for the group number.
- To ensure each instance only processes its assigned rows, connect a Filter Rows command immediately after the Runtime Inputs command and before other commands. The filter will isolate records by group number, ensuring all subsequent commands only operate on the correct rows.
Note: The Search Columns field is 0-based.
- In Chain Settings, ensure the Allow concurrent runs option is enabled.
Step 3: Pass Through the File and Group Number
- In the Primary Chain, add one Run Chain command for each group number used in the
NTILEfunction (e.g., 3 commands forNTILE(3)).- Data File Runtime Input: select Advanced Query > Result output from the Variable Panel.
- Group Number Runtime Input: A unique number from 1 up to the total number of groups.
Result
Your chain is now processing three times as many rows from your control sheet at once. You can scale this further by increasing the NTILE number and adding corresponding Run Chain commands.
Warning
- Avoid running too many parallel chains at once, as doing so can exceed platform limits and cause commands to fail. As a best practice, the number of parallel chains should be less than 10.
- All chain solutions should be thoroughly tested against edge cases and all relevant data types before being used in live or production environments.
- Chains with more than six nested levels of Run Chain usage may not export or import correctly.
Additional Resources
For more information about Chain Control Sheets, review some of our other resources
- For some more foundational information, review our Using Control Sheets.
- For a popular use case of control sheets, review our Control Sheet Scheduler Chain template.