# The effect of refresh on segment merging

**URL:** <https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972>\
**Category:** Elasticsearch\
**Created:** [April 20, 2017, 3:26am UTC](https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972 "2017-04-20T03:26:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [April 20, 2017, 3:26am UTC](https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972/1 "2017-04-20T03:26:20Z")

</div>

I know that a refresh will create new Lucene segments from newly indexed  
documents, but does the refresh directly signal the Lucene merge scheduler  
in any way? If there are no documents being indexed, does a positive  
refresh interval (\> 0ms) have any effect on merging?

We are facing a scenario were too many segments on a relatively small index  
is causing search performance issues. Too much time is spent advancing  
between segments and only an optimize (er, force merge) will alleviate the  
issue.

---

<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:** [April 20, 2017, 7:52am UTC](https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972/2 "2017-04-20T07:52:44Z")

</div>

> [@Ivan](#):
>
> does the refresh directly signal the Lucene merge schedulerin any way?

Not that I know of.

> [@Ivan](#):
>
> If there are no documents being indexed, does a positiverefresh interval (\> 0ms) have any effect on merging?

It shouldn't as there are no new segments to create and thus merge/

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [April 20, 2017, 4:07pm UTC](https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972/3 "2017-04-20T16:07:28Z")

</div>

Thanks Mark. Your responses are as expected. A co-worker is convinced we  
need to set the refresh interval to something other than -1, even if we run  
an explicit refresh after a bulk indexing batch. 🙂

Our queries are adversely affected by the number of segments, which we  
never see decreasing. We index a mostly small number of documents every  
twenty minutes, which may include updates (deletes). Current attempt is to  
increase the number of max segments so that no one segment is over 1gb in  
hopes that the merge scheduler can do its thing.

---

<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:** [April 20, 2017, 11:37pm UTC](https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972/4 "2017-04-20T23:37:25Z")

</div>

> [@Ivan](#):
>
> A co-worker is convinced weneed to set the refresh interval to something other than -1, even if we runan explicit refresh after a bulk indexing batch.

Nope, that'll force the flush into the segments. You _may_ want to run a force merge though.

---

<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:** [May 18, 2017, 11:38pm UTC](https://discuss.elastic.co/t/the-effect-of-refresh-on-segment-merging/82972/5 "2017-05-18T23:38:01Z")

</div>

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