# Is it best practice to call \_forcemerge on active index?

**URL:** <https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488>\
**Category:** Elasticsearch\
**Created:** [January 3, 2017, 10:38pm UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488 "2017-01-03T22:38:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [January 3, 2017, 10:38pm UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/1 "2017-01-03T22:38:37Z")

</div>

I am going to optimize my indices daily with automatic tool which will simply call \_forcemerge?max\_num\_segments=1 all indices one by one. During the optimizing, there are still querying and indexing on all indices.

Is it best practice to merge the active index with \_forcemerge?max\_num\_segments=1?

---

<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:** [January 3, 2017, 10:54pm UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/2 "2017-01-03T22:54:19Z")

</div>

It is not, because segment counts are changing.

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [January 4, 2017, 1:57am UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/3 "2017-01-04T01:57:09Z")

</div>

Thanks.  
So any approaches to optimize the active index? Our search service must be 24x24 alive and the index is queried and indexed all the time, so cannot close, optimize then open.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [January 4, 2017, 2:11am UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/4 "2017-01-04T02:11:51Z")

</div>

`_forcemerge` is nice for indexes that you know you are done writing to. Otherwise you just continue to make your changes to the index, relying on the background merge process to clean up the deleted documents as it goes.

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [January 4, 2017, 2:36am UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/5 "2017-01-04T02:36:08Z")

</div>

If we can temporarily stop the indexing, is it OK to do \_forcemerge on index which are still being heavily queried?  
Per our performance testing, seems \_forcemerge has no obvious impact on query. But want to double confirm.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 4, 2017, 6:17am UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/6 "2017-01-04T06:17:18Z")

</div>

There is no need to call forcemerge if you are going to append new documents after that.  
What problem are you trying to solve here?

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [January 4, 2017, 6:21am UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/7 "2017-01-04T06:21:16Z")

</div>

In our previous testing, we found low query perf on a certain index, and after we called \_forcemerge?max\_num\_segments=1, this issue was gone.

So I think maybe we can optimize the index regularly to avoid the potential bad query perf in future.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [January 4, 2017, 1:05pm UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/8 "2017-01-04T13:05:44Z")

</div>

Calling forcemerge on an index you are actively updating will make it  
perform better for a short time and then much worse. It is only a good  
choice if you aren't going to modify the index again.

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [January 4, 2017, 9:24pm UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/9 "2017-01-04T21:24:02Z")

</div>

Per your answer, optimize on active index will make it "perform better for a short time and then much worse".  
Why "then much worse" ?

Also, if I can make sure stop the updating before forcemerge and then resume the updating after forcemerge done, should be no perf impact, right?

---

<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:** [February 1, 2017, 9:24pm UTC](https://discuss.elastic.co/t/is-it-best-practice-to-call--forcemerge-on-active-index/70488/10 "2017-02-01T21:24:41Z")

</div>

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