# Elasticsearch slow at the beginning of searching , and segment memory is 0

**URL:** <https://discuss.elastic.co/t/elasticsearch-slow-at-the-beginning-of-searching-and-segment-memory-is-0/330638>\
**Category:** Elasticsearch\
**Created:** [April 24, 2023, 11:18am UTC](https://discuss.elastic.co/t/elasticsearch-slow-at-the-beginning-of-searching-and-segment-memory-is-0/330638 "2023-04-24T11:18:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuhan\_zhang2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuhan_zhang2/32/120134_2.png) [@yuhan\_zhang2](https://discuss.elastic.co/u/yuhan_zhang2)\
**Post date:** [April 24, 2023, 11:18am UTC](https://discuss.elastic.co/t/elasticsearch-slow-at-the-beginning-of-searching-and-segment-memory-is-0/330638/1 "2023-04-24T11:18:47Z")

</div>

When I was testing the performance on 10 millions of docs, I found the performance was really bad at the beginning (~20s) but fast after thousands of search.

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

Then I use `_cat/segments?v=true` to check my segments and the memory they cost, and found that "size.memory" are all 0! I think this is the reason that make my query so slow.

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

And I wonder how to set the configration to put the segments all in memory.

---

<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 25, 2023, 11:08pm UTC](https://discuss.elastic.co/t/elasticsearch-slow-at-the-beginning-of-searching-and-segment-memory-is-0/330638/2 "2023-04-25T23:08:14Z")

</div>

> [@yuhan\_zhang2](#):
>
> When I was testing the performance on 10 millions of docs, I found the performance was really bad at the beginning (~20s) but fast after thousands of search.

That's pretty typical, as Elasticsearch (and the OS) needs to know what is being requested to then start to cache things for faster future response/

> [@yuhan\_zhang2](#):
>
> And I wonder how to set the configration to put the segments all in memory.

I don't believe there is a way to force this.

---

<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 23, 2023, 11:08pm UTC](https://discuss.elastic.co/t/elasticsearch-slow-at-the-beginning-of-searching-and-segment-memory-is-0/330638/3 "2023-05-23T23:08:26Z")

</div>

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