# Max Documents in a Segment

**URL:** https://discuss.elastic.co/t/max-documents-in-a-segment/156117
**Category:** Elasticsearch
**Created:** [November 9, 2018, 11:50pm UTC](https://discuss.elastic.co/t/max-documents-in-a-segment/156117 "2018-11-09T23:50:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![djtecha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/djtecha/32/54011_2.png) [@djtecha](https://discuss.elastic.co/u/djtecha)
#### Post date: [November 9, 2018, 11:50pm UTC](https://discuss.elastic.co/t/max-documents-in-a-segment/156117/1 "2018-11-09T23:50:04Z")

</div>

I'm curious if anyone knows lucene enough to explain what the max number of documents or data size should exist in a segment. As in at what point does forcemerging an index have diminishing returns? If I have a 50GB index with 300M documents, is it better to have 1 5 or 10 Segments?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [November 10, 2018, 2:19am UTC](https://discuss.elastic.co/t/max-documents-in-a-segment/156117/2 "2018-11-10T02:19:15Z")

</div>

The max doc limit works on a shard level, not a segment, and it's 2^32-1.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [November 10, 2018, 9:02am UTC](https://discuss.elastic.co/t/max-documents-in-a-segment/156117/3 "2018-11-10T09:02:13Z")

</div>

This depends on what you are trying to achieve by the force merge. If you are looking to speed up queries I suspect you need to benchmark to see what the ideal segment size is. If you on the other hand are looking to reduce heap usage, force merging down to a single shard is always beneficial, as described in [this webinar](https://www.elastic.co/webinars/optimizing-storage-efficiency-in-elasticsearch).

---

<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: [December 8, 2018, 9:02am UTC](https://discuss.elastic.co/t/max-documents-in-a-segment/156117/4 "2018-12-08T09:02:14Z")

</div>

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