# Parallel execution of bulk request

**URL:** <https://discuss.elastic.co/t/parallel-execution-of-bulk-request/205030>\
**Category:** Elasticsearch\
**Created:** [October 24, 2019, 9:29am UTC](https://discuss.elastic.co/t/parallel-execution-of-bulk-request/205030 "2019-10-24T09:29:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishant.saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishant.saini/32/41489_2.png) [@nishant.saini](https://discuss.elastic.co/u/nishant.saini)\
**Post date:** [October 24, 2019, 9:29am UTC](https://discuss.elastic.co/t/parallel-execution-of-bulk-request/205030/1 "2019-10-24T09:29:56Z")

</div>

As it is known that the order of execution of requests in a bulk request is not guaranteed, reason being the execution can happen on different nodes. But I'm curious to know what would happen in a case when the bulk request contain all the request for a single document id.

Lets assume a bulk request has three requests R1, R2, R3 where,  
R1 : updates document with document id D1  
R2 : updates document with document id D1  
R3 : delete document with document id D1

Is it possible that R3 executes before R1 or R2 even though all these requests will be executed on the same node as all of them are for document D1?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 24, 2019, 11:54am UTC](https://discuss.elastic.co/t/parallel-execution-of-bulk-request/205030/2 "2019-10-24T11:54:20Z")

</div>

If a bulk contains multiple operations on the same document then they are processed in order. However this is rather inefficient and if at all possible you should prefer to combine these operations into a single one before sending them to Elasticsearch. In your example, it would save a lot of time simply to delete the document and not send the two updates to Elasticsearch at all.

---

<div class="post-metadata">

**Author:** ![nishant.saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishant.saini/32/41489_2.png) [@nishant.saini](https://discuss.elastic.co/u/nishant.saini)\
**Post date:** [October 25, 2019, 3:03am UTC](https://discuss.elastic.co/t/parallel-execution-of-bulk-request/205030/3 "2019-10-25T03:03:44Z")

</div>

Thanks for the clarification 🙂

> [@DavidTurner](#):
>
> In your example, it would save a lot of time simply to delete the document and not send the two updates to Elasticsearch at all.

The example was hypothetical just for the sake of clarity. Thanks for the suggestion though as the point you mentioned are worth taking a note.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 22, 2019, 3:06am UTC](https://discuss.elastic.co/t/parallel-execution-of-bulk-request/205030/4 "2019-11-22T03:06:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
