# Max number of segments in elasticsearch

**URL:** https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210
**Category:** Elasticsearch
**Created:** [October 4, 2016, 7:26pm UTC](https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210 "2016-10-04T19:26:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![suanmeiguo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suanmeiguo/32/11758_2.png) [@suanmeiguo](https://discuss.elastic.co/u/suanmeiguo)
#### Post date: [October 4, 2016, 7:26pm UTC](https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210/1 "2016-10-04T19:26:56Z")

</div>

Is there a parameter in elasticsearch to set the max number of underlying segments in the whole cluster? Or is there any parameters about segments?

I know there's a `max_num_segments` when using the optimize API, but I'm looking for parameters that controls segments in general.

For example, is there a parameter to control how many segments you can have in each index? or how often to merge the segments (instead of waiting a segment become too big)?

Appreciate!

---

<div class="post-metadata">

### Author: ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)
#### Post date: [October 4, 2016, 7:36pm UTC](https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210/2 "2016-10-04T19:36:23Z")

</div>

Sort of. Typically you can get close to controlling how segments are laid out with the [merge policy](https://www.elastic.co/guide/en/elasticsearch/reference/1.4/index-modules-merge.html). Which is deprecated, and in fact almost all these settings are [removed in 2.x](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html) in favor of an auto-throttling API.

Generally speaking is, best practice is not focus on narrowing down to just one or few segments. The tiered segments have advantages with parallelism and "graduating" long-lived documents to bigger/more stable segments (much like a garbage collector).

Is there a higher level problem you're trying to solve? Like indexing/search is slow, etc?

---

<div class="post-metadata">

### Author: ![suanmeiguo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suanmeiguo/32/11758_2.png) [@suanmeiguo](https://discuss.elastic.co/u/suanmeiguo)
#### Post date: [October 4, 2016, 8:47pm UTC](https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210/3 "2016-10-04T20:47:57Z")

</div>

Yeah basically I have a giant index (300M rows and about 500G all primary shards combined), and I'm constantly updating (80%) and inserting (20%) into it.

The concern is, when the index grows too large, we're gonna have too many segments or too big segments, which leads to a performance decrease. So I'm trying to figure out if this will be an issue, and how I can resolve it.

Thanks for the quick response!

---

<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: [October 5, 2016, 8:32am UTC](https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210/4 "2016-10-05T08:32:08Z")

</div>

You might be better off splitting the index?

---

<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: [July 5, 2017, 10:14pm UTC](https://discuss.elastic.co/t/max-number-of-segments-in-elasticsearch/62210/5 "2017-07-05T22:14:51Z")

</div>


