Skip to main content

Batch Index

Uncontrolled node

Overview

The Batch Index node is designed for workflows that process data in batches. When a workflow is configured to run in batch mode (processing multiple chunks of data from a database table), this node outputs the current batch index (0-based) that the workflow is executing.

This node is typically used in conjunction with the Batch Data, Batch Length, and Batch Size nodes to create workflows that handle large datasets by breaking them into manageable chunks.

Editor Mode Behavior

When testing in the workflow editor, this node always returns 0 as the batch index, since batch processing only occurs during actual workflow execution.

Inputs

This node has no inputs.

Outputs

OutputTypeDescription
indexNumberThe current batch index (0-based) of the workflow execution. Returns 0 when testing in the editor.

Runtime Behavior and Defaults

  • Uncontrolled Node: This node runs automatically when its output is requested by downstream nodes. It does not require an event trigger.
  • Batch Mode: When the workflow runs in batch mode, the node retrieves the current batch index from the workflow's internal batchOpts configuration.
  • Editor Mode: During testing in the workflow editor, the node always returns 0.
  • Default Value: If no batch options are available, the node defaults to returning 0.

Example Usage

Basic Batch Processing Setup

Here's how to use Batch Index with other batch nodes to process data in chunks:

  1. Connect a Start node to a Batch Data node
  2. Connect the Batch Data node's data output to your processing logic
  3. Connect the Batch Index node to track which batch is currently running
  4. Use the index to log progress or calculate offsets:
[Start] → [Batch Data] → [Your Processing Logic]

[Batch Index] → [Log Current Batch]

Calculating Progress

Combine with Batch Length to calculate completion percentage:

[Batch Index] ──┐
├── [Formula: (index / length) * 100] → [Progress Percentage]
[Batch Length] ─┘

Conditional Logic per Batch

Use the index to perform different actions for specific batches:

[Batch Index] → [Compare: index == 0] → [If True] → [First Batch Setup]
→ [If False] → [Standard Processing]
Batch Processing Context

Batch processing is configured at the workflow level when setting up scheduled runs or API endpoints. The Batch Index node automatically picks up the current iteration from the workflow runtime environment without requiring any manual configuration.