# Do very large segments lead to a significant increase in slow logs?

**URL:** <https://discuss.elastic.co/t/do-very-large-segments-lead-to-a-significant-increase-in-slow-logs/369409>\
**Category:** Elasticsearch\
**Created:** [October 25, 2024, 9:35am UTC](https://discuss.elastic.co/t/do-very-large-segments-lead-to-a-significant-increase-in-slow-logs/369409 "2024-10-25T09:35:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangxr1985](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wangxr1985/32/117798_2.png) [@wangxr1985](https://discuss.elastic.co/u/wangxr1985)\
**Post date:** [October 25, 2024, 9:35am UTC](https://discuss.elastic.co/t/do-very-large-segments-lead-to-a-significant-increase-in-slow-logs/369409/1 "2024-10-25T09:35:44Z")

</div>

I have an Elasticsearch index that continuously receives new data, along with a certain proportion of update and delete operations. As a result, the docs.deleted count for this index is gradually increasing, and after a few weeks, it reaches the deletes\_pct\_allowed threshold, triggering a cleanup. The CPU usage of the cluster nodes and the average query time show a constant increase, and then suddenly drop after a few weeks.

To shorten this cycle, I added a scheduled task in crontab that executes \_forcemerge?only\_expunge\_deletes=true daily to clean up deleted documents. However, this raises an issue: some larger segments cannot participate in merging due to being close to the max\_merged\_segment limit of 5GB, hence only\_expunge\_deletes does not allow these segments to be merged.

To clean up the deleted documents within these large segments, I performed a force merge using \_forcemerge?max\_num\_segments=1 two days ago. After executing this, a very large segment (15GB) was generated, and many slow logs exceeding 1 second appeared, whereas previously there were almost none exceeding 1 second.

Could this increase in slow logs be caused by the segments being too large? Given the current situation I am facing, how should I address this? It seems that segments can only continue to grow larger and there is no way to shrink them.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/a/9ad71bc20e09464f4be976f6744a9a0c3503a72b.png)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/d/5dd5321a69935ec9772f666a77d316fec42a0a4a.png)
