# Update counters vs multiple documents

**URL:** <https://discuss.elastic.co/t/update-counters-vs-multiple-documents/79754>\
**Category:** Elasticsearch\
**Created:** [March 23, 2017, 1:22pm UTC](https://discuss.elastic.co/t/update-counters-vs-multiple-documents/79754 "2017-03-23T13:22:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eldad\_Moneta](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@Eldad\_Moneta](https://discuss.elastic.co/u/Eldad_Moneta)\
**Post date:** [March 23, 2017, 1:22pm UTC](https://discuss.elastic.co/t/update-counters-vs-multiple-documents/79754/1 "2017-03-23T13:22:31Z")

</div>

Hi,

I have many millions of documents representing thousands of different metrics.  
Currently, we use bulk update requests that increment all counters in the document if it is already present.  
Using Update instead of indexing a new document has its performance hit during the update process (due to fetching the previous doc, updating and then deleting the old doc), so I thought about switching to append the only mode.  
When querying, I have no problem handling either of the above cases, but I'm concerned about performance during the query and aggregations.  
e.g  
If I currently have the following documents:  
`{myid: 'aaa', counter1:1, counter2:4} {myid: 'bbb', counter1:3, counter2:3}`  
After updating with `{myid: 'aaa', counter1:2, counter2:0}` I will end up with:  
`{myid: 'aaa', counter1:3, counter2:4} {myid: 'bbb', counter1:3, counter2:3}`  
While the append only approach will leave me with:  
`{myid: 'aaa', counter1:1, counter2:4} {myid: 'bbb', counter1:3, counter2:3} {myid: 'aaa', counter1:2, counter2:0}`

My queries are mainly: show sum of counters for 'aaa'\counter1

Thanks all!

---

<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:** [April 20, 2017, 1:22pm UTC](https://discuss.elastic.co/t/update-counters-vs-multiple-documents/79754/2 "2017-04-20T13:22:36Z")

</div>

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