# How to speed up the segment merging

**URL:** https://discuss.elastic.co/t/how-to-speed-up-the-segment-merging/260044
**Category:** Elasticsearch
**Created:** [January 4, 2021, 1:44am UTC](https://discuss.elastic.co/t/how-to-speed-up-the-segment-merging/260044 "2021-01-04T01:44:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![chemboking](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chemboking/32/79162_2.png) [@chemboking](https://discuss.elastic.co/u/chemboking)
#### Post date: [January 4, 2021, 1:44am UTC](https://discuss.elastic.co/t/how-to-speed-up-the-segment-merging/260044/1 "2021-01-04T01:44:57Z")

</div>

I don't understand why merging a 8GB(total) shard into one 3GB segment shard should take about 6 minutes, while all the indicators(io/cpu/memory/gc) of the machine(ssd/32 cores/30GB jvm/64GB total/swap disabled) are very low.

I have tried the following configurations:

- set the thread\_pool.force\_merge.size to 4, I understand that merging is one thread per shard, but there is still one merge thread(through remote debug) after i put two shards in one ES node, and the merging time is twice that of the one shard. What did i miss?

- set the data directory to the /dev/shm, and the process doesn't seem to have changed much.

BTW, here is my scenario(3 ES nodes in 3 machines separately， one index with 6 shards, 0 replica, each machine shall have two shards, ES version 7.7.1)

1. create the index, set the refresh interval to -1
2. bulk into the es
3. stop writing, call refresh and set refresh interval to 60s
4. force merge into 1 segments by calling the \_forcemerge?max\_num\_segments=1
5. wait until the segments become 1 and prepare the alias to take traffic

After merging into 1 segment, the size of the whole index is about 14GB, 2 million docs.

---

<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, 2021, 1:45am UTC](https://discuss.elastic.co/t/how-to-speed-up-the-segment-merging/260044/2 "2021-02-01T01:45:07Z")

</div>

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