# Parallell processing should be activities or workers?

**URL:** <https://community.temporal.io/t/parallell-processing-should-be-activities-or-workers/9271>\
**Category:** Community Support\
**Created:** [August 23, 2023, 11:08am UTC](https://community.temporal.io/t/parallell-processing-should-be-activities-or-workers/9271 "2023-08-23T11:08:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitor\_Goncalves](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/vitor_goncalves/32/4200_2.png) [@Vitor\_Goncalves](https://community.temporal.io/u/Vitor_Goncalves)\
**Post date:** [August 23, 2023, 11:08am UTC](https://community.temporal.io/t/parallell-processing-should-be-activities-or-workers/9271/1 "2023-08-23T11:08:59Z")

</div>

Hey guys,

Sorry if I am question is a bit silly since I only have like 3 months of use with Temporal so I am still fresh. Being said that right now I have like a table with 50k records and each row needs to be processed some data that can take some time. So I decided for each row to initiate a workflow on temporal and process it. But it seems there is some spoil over that data, meaning that data that was being used on workflow-ID-A sometimes is passed into workflow-id-B.

So I am a bit lost in what I am doing wrong. Should I have created one workflow (since this is cronjob) and for each row just create an activity?

Any help would be highly appreciated,  
Thanks

---

<div class="post-metadata">

**Author:** ![antonio.perez](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/antonio.perez/32/2417_2.png) [@antonio.perez](https://community.temporal.io/u/antonio.perez)\
**Post date:** [August 23, 2023, 5:13pm UTC](https://community.temporal.io/t/parallell-processing-should-be-activities-or-workers/9271/2 "2023-08-23T17:13:36Z")

</div>

Hi @Vitor_Goncalves ,

there are silly questions.

It seems you could implement this procesing the rows in batches.

You can have a workflow with one activity that poll the x first number of rows (let say 100), and them for each row create an activity or child workflow (it dependes if processing each row involve one or more actions/activities) to process each row.

> But it seems there is some spoil over that data, meaning that data that was being used on workflow-ID-A sometimes is passed into workflow-id-B.  
> Processing the rows sequentially will allow you to pass any data from the previous row to the next processor (activity/child workflow)

After processing the first batch, you can invoke [continueAsNew](https://docs.temporal.io/workflows#continue-as-new) pasing the offset to the next workflow run, that will use the offset in the first activity to poll the next x number of rows, and so on.

We have an example in java with different approaches [https://github.com/temporalio/samples-java/tree/main/core/src/main/java/io/temporal/samples/batch](https://github.com/temporalio/samples-java/tree/main/core/src/main/java/io/temporal/samples/batch)

Let me know if it helps,  
Antonio

---

<div class="post-metadata">

**Author:** ![Vitor\_Goncalves](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/vitor_goncalves/32/4200_2.png) [@Vitor\_Goncalves](https://community.temporal.io/u/Vitor_Goncalves)\
**Post date:** [August 24, 2023, 9:28am UTC](https://community.temporal.io/t/parallell-processing-should-be-activities-or-workers/9271/3 "2023-08-24T09:28:45Z")

</div>

Hey @antonio.perez ,

Thank you very much for your help. I will change as you said.

Thanks,  
Vitor
